; 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.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 @_ZN16MACVelocityField4setWEiiid(ptr noundef nonnull align 8 dereferenceable(148), i32 noundef, i32 noundef, i32 noundef, double noundef) #1 align 2

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

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

16:                                               ; preds = %86, %4
  %17 = load i32, ptr %9, align 4, !tbaa !9
  %18 = getelementptr inbounds %class.MACVelocityField, ptr %15, i32 0, i32 3
  %19 = load i32, ptr %18, align 4, !tbaa !11
  %20 = add nsw i32 %19, 1
  %21 = icmp slt i32 %17, %20
  br i1 %21, label %23, label %22

22:                                               ; preds = %16
  store i32 2, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  br label %89

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

24:                                               ; preds = %82, %23
  %25 = load i32, ptr %11, align 4, !tbaa !9
  %26 = getelementptr inbounds %class.MACVelocityField, ptr %15, i32 0, i32 2
  %27 = load i32, ptr %26, align 8, !tbaa !17
  %28 = icmp slt i32 %25, %27
  br i1 %28, label %30, label %29

29:                                               ; preds = %24
  store i32 5, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  br label %85

30:                                               ; preds = %24
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  store i32 0, ptr %12, align 4, !tbaa !9
  br label %31

31:                                               ; preds = %78, %30
  %32 = load i32, ptr %12, align 4, !tbaa !9
  %33 = getelementptr inbounds %class.MACVelocityField, ptr %15, i32 0, i32 1
  %34 = load i32, ptr %33, align 4, !tbaa !18
  %35 = icmp slt i32 %32, %34
  br i1 %35, label %37, label %36

36:                                               ; preds = %31
  store i32 8, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  br label %81

37:                                               ; preds = %31
  call void @llvm.lifetime.start.p0(i64 1, ptr %13) #4
  %38 = load i32, ptr %12, align 4, !tbaa !9
  %39 = load i32, ptr %11, align 4, !tbaa !9
  %40 = load i32, ptr %9, align 4, !tbaa !9
  %41 = load i32, ptr %6, align 4, !tbaa !9
  %42 = load ptr, ptr %8, align 8, !tbaa !5
  %43 = call noundef zeroext i1 @_ZN16MACVelocityField27_isFaceBorderingLayerIndexWEiiiiR7Array3dIiE(ptr noundef nonnull align 8 dereferenceable(148) %15, i32 noundef %38, i32 noundef %39, i32 noundef %40, i32 noundef %41, ptr noundef nonnull align 8 dereferenceable(36) %42)
  br i1 %43, label %44, label %59

44:                                               ; preds = %37
  %45 = load i32, ptr %12, align 4, !tbaa !9
  %46 = load i32, ptr %11, align 4, !tbaa !9
  %47 = load i32, ptr %9, align 4, !tbaa !9
  %48 = load i32, ptr %6, align 4, !tbaa !9
  %49 = sub nsw i32 %48, 1
  %50 = load ptr, ptr %8, align 8, !tbaa !5
  %51 = call noundef zeroext i1 @_ZN16MACVelocityField27_isFaceBorderingLayerIndexWEiiiiR7Array3dIiE(ptr noundef nonnull align 8 dereferenceable(148) %15, i32 noundef %45, i32 noundef %46, i32 noundef %47, i32 noundef %49, ptr noundef nonnull align 8 dereferenceable(36) %50)
  br i1 %51, label %59, label %52

52:                                               ; preds = %44
  %53 = load ptr, ptr %7, align 8, !tbaa !5
  %54 = load i32, ptr %12, align 4, !tbaa !9
  %55 = load i32, ptr %11, align 4, !tbaa !9
  %56 = load i32, ptr %9, align 4, !tbaa !9
  %57 = call noundef zeroext i1 @_ZN17FluidMaterialGrid21isFaceBorderingSolidWEiii(ptr noundef nonnull align 8 dereferenceable(88) %53, i32 noundef %54, i32 noundef %55, i32 noundef %56)
  %58 = xor i1 %57, true
  br label %59

59:                                               ; preds = %52, %44, %37
  %60 = phi i1 [ false, %44 ], [ false, %37 ], [ %58, %52 ]
  %61 = zext i1 %60 to i8
  store i8 %61, ptr %13, align 1, !tbaa !19
  %62 = load i8, ptr %13, align 1, !tbaa !19, !range !20, !noundef !21
  %63 = trunc i8 %62 to i1
  br i1 %63, label %64, label %77

64:                                               ; preds = %59
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  %65 = load i32, ptr %12, align 4, !tbaa !9
  %66 = load i32, ptr %11, align 4, !tbaa !9
  %67 = load i32, ptr %9, align 4, !tbaa !9
  %68 = load i32, ptr %6, align 4, !tbaa !9
  %69 = load ptr, ptr %8, align 8, !tbaa !5
  %70 = call noundef double @_ZN16MACVelocityField32_getExtrapolatedVelocityForFaceWEiiiiR7Array3dIiE(ptr noundef nonnull align 8 dereferenceable(148) %15, i32 noundef %65, i32 noundef %66, i32 noundef %67, i32 noundef %68, ptr noundef nonnull align 8 dereferenceable(36) %69)
  store double %70, ptr %14, align 8, !tbaa !22
  %71 = load i32, ptr %12, align 4, !tbaa !9
  %72 = load i32, ptr %11, align 4, !tbaa !9
  %73 = load i32, ptr %9, align 4, !tbaa !9
  %74 = load double, ptr %14, align 8, !tbaa !22
  %75 = fptrunc double %74 to float
  %76 = fpext float %75 to double
  call void @_ZN16MACVelocityField4setWEiiid(ptr noundef nonnull align 8 dereferenceable(148) %15, i32 noundef %71, i32 noundef %72, i32 noundef %73, double noundef %76)
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  br label %77

77:                                               ; preds = %64, %59
  call void @llvm.lifetime.end.p0(i64 1, ptr %13) #4
  br label %78

78:                                               ; preds = %77
  %79 = load i32, ptr %12, align 4, !tbaa !9
  %80 = add nsw i32 %79, 1
  store i32 %80, ptr %12, align 4, !tbaa !9
  br label %31, !llvm.loop !23

81:                                               ; preds = %36
  br label %82

82:                                               ; preds = %81
  %83 = load i32, ptr %11, align 4, !tbaa !9
  %84 = add nsw i32 %83, 1
  store i32 %84, ptr %11, align 4, !tbaa !9
  br label %24, !llvm.loop !25

85:                                               ; preds = %29
  br label %86

86:                                               ; preds = %85
  %87 = load i32, ptr %9, align 4, !tbaa !9
  %88 = add nsw i32 %87, 1
  store i32 %88, ptr %9, align 4, !tbaa !9
  br label %16, !llvm.loop !26

89:                                               ; preds = %22
  ret void
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN16MACVelocityField27_isFaceBorderingLayerIndexWEiiiiR7Array3dIiE(ptr noundef nonnull align 8 dereferenceable(148), i32 noundef, i32 noundef, i32 noundef, i32 noundef, ptr noundef nonnull align 8 dereferenceable(36)) #2 align 2

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

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 = { inlinehint 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 = { "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 #4 = { 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 12}
!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 8}
!18 = !{!12, !10, i64 4}
!19 = !{!16, !16, i64 0}
!20 = !{i8 0, i8 2}
!21 = !{}
!22 = !{!14, !14, i64 0}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.mustprogress"}
!25 = distinct !{!25, !24}
!26 = distinct !{!26, !24}


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

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

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

.preheader32.lr.ph:                               ; preds = %4
  %7 = getelementptr inbounds i8, ptr %0, i64 8
  %8 = getelementptr inbounds i8, ptr %0, i64 4
  %9 = add nsw i32 %1, -1
  %10 = load i32, ptr %7, align 8, !tbaa !15
  %11 = icmp sgt i32 %10, 0
  br i1 %11, label %.preheader32, label %._crit_edge39

.preheader32:                                     ; preds = %.preheader32.lr.ph, %._crit_edge35
  %12 = phi i32 [ %21, %._crit_edge35 ], [ %6, %.preheader32.lr.ph ]
  %13 = phi i32 [ %22, %._crit_edge35 ], [ %10, %.preheader32.lr.ph ]
  %14 = phi i32 [ %23, %._crit_edge35 ], [ %10, %.preheader32.lr.ph ]
  %.037 = phi i32 [ %24, %._crit_edge35 ], [ 0, %.preheader32.lr.ph ]
  %15 = icmp sgt i32 %14, 0
  %16 = load i32, ptr %8, align 4
  %17 = icmp sgt i32 %16, 0
  %or.cond = select i1 %15, i1 %17, i1 false
  br i1 %or.cond, label %.preheader, label %._crit_edge35

._crit_edge39:                                    ; preds = %._crit_edge35, %.preheader32.lr.ph, %4
  ret void

.preheader:                                       ; preds = %.preheader32, %._crit_edge
  %18 = phi i32 [ %25, %._crit_edge ], [ %13, %.preheader32 ]
  %19 = phi i32 [ %26, %._crit_edge ], [ %16, %.preheader32 ]
  %.03134 = phi i32 [ %27, %._crit_edge ], [ 0, %.preheader32 ]
  %20 = icmp sgt i32 %19, 0
  br i1 %20, label %.lr.ph, label %._crit_edge

._crit_edge35.loopexit:                           ; preds = %._crit_edge
  %.pre42 = load i32, ptr %5, align 4, !tbaa !5
  br label %._crit_edge35

._crit_edge35:                                    ; preds = %._crit_edge35.loopexit, %.preheader32
  %21 = phi i32 [ %.pre42, %._crit_edge35.loopexit ], [ %12, %.preheader32 ]
  %22 = phi i32 [ %25, %._crit_edge35.loopexit ], [ %13, %.preheader32 ]
  %23 = phi i32 [ %25, %._crit_edge35.loopexit ], [ %14, %.preheader32 ]
  %24 = add nuw nsw i32 %.037, 1
  %.not.not = icmp slt i32 %.037, %21
  br i1 %.not.not, label %.preheader32, label %._crit_edge39, !llvm.loop !16

._crit_edge.loopexit:                             ; preds = %.critedge
  %.pre = load i32, ptr %7, align 8, !tbaa !15
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %.preheader
  %25 = phi i32 [ %.pre, %._crit_edge.loopexit ], [ %18, %.preheader ]
  %26 = phi i32 [ %39, %._crit_edge.loopexit ], [ %19, %.preheader ]
  %27 = add nuw nsw i32 %.03134, 1
  %28 = icmp slt i32 %27, %25
  br i1 %28, label %.preheader, label %._crit_edge35.loopexit, !llvm.loop !19

.lr.ph:                                           ; preds = %.preheader, %.critedge
  %.03033 = phi i32 [ %38, %.critedge ], [ 0, %.preheader ]
  %29 = tail call noundef zeroext i1 @_ZN16MACVelocityField27_isFaceBorderingLayerIndexWEiiiiR7Array3dIiE(ptr noundef nonnull align 8 dereferenceable(148) %0, i32 noundef %.03033, i32 noundef %.03134, i32 noundef %.037, i32 noundef %1, ptr noundef nonnull align 8 dereferenceable(36) %3)
  br i1 %29, label %30, label %.critedge

30:                                               ; preds = %.lr.ph
  %31 = tail call noundef zeroext i1 @_ZN16MACVelocityField27_isFaceBorderingLayerIndexWEiiiiR7Array3dIiE(ptr noundef nonnull align 8 dereferenceable(148) %0, i32 noundef %.03033, i32 noundef %.03134, i32 noundef %.037, i32 noundef %9, ptr noundef nonnull align 8 dereferenceable(36) %3)
  br i1 %31, label %.critedge, label %32

32:                                               ; preds = %30
  %33 = tail call noundef zeroext i1 @_ZN17FluidMaterialGrid21isFaceBorderingSolidWEiii(ptr noundef nonnull align 8 dereferenceable(88) %2, i32 noundef %.03033, i32 noundef %.03134, i32 noundef %.037)
  br i1 %33, label %.critedge, label %34

34:                                               ; preds = %32
  %35 = tail call noundef double @_ZN16MACVelocityField32_getExtrapolatedVelocityForFaceWEiiiiR7Array3dIiE(ptr noundef nonnull align 8 dereferenceable(148) %0, i32 noundef %.03033, i32 noundef %.03134, i32 noundef %.037, i32 noundef %1, ptr noundef nonnull align 8 dereferenceable(36) %3)
  %36 = fptrunc double %35 to float
  %37 = fpext float %36 to double
  tail call void @_ZN16MACVelocityField4setWEiiid(ptr noundef nonnull align 8 dereferenceable(148) %0, i32 noundef %.03033, i32 noundef %.03134, i32 noundef %.037, double noundef %37)
  br label %.critedge

.critedge:                                        ; preds = %30, %.lr.ph, %34, %32
  %38 = add nuw nsw i32 %.03033, 1
  %39 = load i32, ptr %8, align 4, !tbaa !20
  %40 = icmp slt i32 %38, %39
  br i1 %40, label %.lr.ph, label %._crit_edge.loopexit, !llvm.loop !21
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN16MACVelocityField27_isFaceBorderingLayerIndexWEiiiiR7Array3dIiE(ptr noundef nonnull align 8 dereferenceable(148), i32 noundef, i32 noundef, i32 noundef, i32 noundef, ptr noundef nonnull align 8 dereferenceable(36)) local_unnamed_addr #1 align 2

declare noundef zeroext i1 @_ZN17FluidMaterialGrid21isFaceBorderingSolidWEiii(ptr noundef nonnull align 8 dereferenceable(88), i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #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 = { inlinehint 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" }

!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 12}
!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 8}
!16 = distinct !{!16, !17, !18}
!17 = !{!"llvm.loop.mustprogress"}
!18 = !{!"llvm.loop.unswitch.partial.disable"}
!19 = distinct !{!19, !17, !18}
!20 = !{!6, !10, i64 4}
!21 = distinct !{!21, !17}


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