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

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

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

; 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 i64 @_ZN7Array3dI5BrickEclEiii(ptr noundef nonnull align 8 dereferenceable(40), i32 noundef, i32 noundef, i32 noundef) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN14FluidBrickGrid21_getNewBrickLocationsER7Array3dI5BrickES3_RS0_IbE(ptr noundef nonnull align 8 dereferenceable(353) %0, ptr noundef nonnull align 8 dereferenceable(40) %1, ptr noundef nonnull align 8 dereferenceable(40) %2, ptr noundef nonnull align 8 dereferenceable(32) %3) #1 align 2 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %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 %struct.Brick, align 4
  %14 = alloca %struct.Brick, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  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) #2
  store i32 0, ptr %9, align 4, !tbaa !9
  br label %16

16:                                               ; preds = %75, %4
  %17 = load i32, ptr %9, align 4, !tbaa !9
  %18 = load ptr, ptr %6, align 8, !tbaa !5
  %19 = getelementptr inbounds %class.Array3d.0, ptr %18, i32 0, i32 2
  %20 = load i32, ptr %19, align 8, !tbaa !11
  %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) #2
  br label %78

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

24:                                               ; preds = %71, %23
  %25 = load i32, ptr %11, align 4, !tbaa !9
  %26 = load ptr, ptr %6, align 8, !tbaa !5
  %27 = getelementptr inbounds %class.Array3d.0, ptr %26, i32 0, i32 1
  %28 = load i32, ptr %27, align 4, !tbaa !16
  %29 = icmp slt i32 %25, %28
  br i1 %29, label %31, label %30

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

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

32:                                               ; preds = %67, %31
  %33 = load i32, ptr %12, align 4, !tbaa !9
  %34 = load ptr, ptr %6, align 8, !tbaa !5
  %35 = getelementptr inbounds %class.Array3d.0, ptr %34, i32 0, i32 0
  %36 = load i32, ptr %35, align 8, !tbaa !17
  %37 = icmp slt i32 %33, %36
  br i1 %37, label %39, label %38

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

39:                                               ; preds = %32
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #2
  %40 = load ptr, ptr %6, align 8, !tbaa !5
  %41 = load i32, ptr %12, align 4, !tbaa !9
  %42 = load i32, ptr %11, align 4, !tbaa !9
  %43 = load i32, ptr %9, align 4, !tbaa !9
  %44 = call i64 @_ZN7Array3dI5BrickEclEiii(ptr noundef nonnull align 8 dereferenceable(40) %40, i32 noundef %41, i32 noundef %42, i32 noundef %43)
  %45 = trunc i64 %44 to i40
  store i40 %45, ptr %13, align 4
  %46 = getelementptr inbounds %struct.Brick, ptr %13, i32 0, i32 1
  %47 = load i8, ptr %46, align 4, !tbaa !18, !range !19, !noundef !20
  %48 = trunc i8 %47 to i1
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #2
  br i1 %48, label %59, label %49

49:                                               ; preds = %39
  %50 = load ptr, ptr %7, align 8, !tbaa !5
  %51 = load i32, ptr %12, align 4, !tbaa !9
  %52 = load i32, ptr %11, align 4, !tbaa !9
  %53 = load i32, ptr %9, align 4, !tbaa !9
  %54 = call i64 @_ZN7Array3dI5BrickEclEiii(ptr noundef nonnull align 8 dereferenceable(40) %50, i32 noundef %51, i32 noundef %52, i32 noundef %53)
  %55 = trunc i64 %54 to i40
  store i40 %55, ptr %14, align 4
  %56 = getelementptr inbounds %struct.Brick, ptr %14, i32 0, i32 1
  %57 = load i8, ptr %56, align 4, !tbaa !18, !range !19, !noundef !20
  %58 = trunc i8 %57 to i1
  br label %59

59:                                               ; preds = %49, %39
  %60 = phi i1 [ false, %39 ], [ %58, %49 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #2
  br i1 %60, label %61, label %66

61:                                               ; preds = %59
  %62 = load ptr, ptr %8, align 8, !tbaa !5
  %63 = load i32, ptr %12, align 4, !tbaa !9
  %64 = load i32, ptr %11, align 4, !tbaa !9
  %65 = load i32, ptr %9, align 4, !tbaa !9
  call void @_ZN7Array3dIbE3setEiiib(ptr noundef nonnull align 8 dereferenceable(32) %62, i32 noundef %63, i32 noundef %64, i32 noundef %65, i1 noundef zeroext true)
  br label %66

66:                                               ; preds = %61, %59
  br label %67

67:                                               ; preds = %66
  %68 = load i32, ptr %12, align 4, !tbaa !9
  %69 = add nsw i32 %68, 1
  store i32 %69, ptr %12, align 4, !tbaa !9
  br label %32, !llvm.loop !21

70:                                               ; preds = %38
  br label %71

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

74:                                               ; preds = %30
  br label %75

75:                                               ; preds = %74
  %76 = load i32, ptr %9, align 4, !tbaa !9
  %77 = add nsw i32 %76, 1
  store i32 %77, ptr %9, align 4, !tbaa !9
  br label %16, !llvm.loop !24

78:                                               ; preds = %22
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7Array3dIbE3setEiiib(ptr noundef nonnull align 8 dereferenceable(32), i32 noundef, i32 noundef, i32 noundef, i1 noundef zeroext) #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 = { 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 = !{!"_ZTS7Array3dI5BrickE", !10, i64 0, !10, i64 4, !10, i64 8, !6, i64 16, !13, i64 24, !14, i64 28, !10, i64 36}
!13 = !{!"bool", !7, i64 0}
!14 = !{!"_ZTS5Brick", !15, i64 0, !13, i64 4}
!15 = !{!"float", !7, i64 0}
!16 = !{!12, !10, i64 4}
!17 = !{!12, !10, i64 0}
!18 = !{!14, !13, i64 4}
!19 = !{i8 0, i8 2}
!20 = !{}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}
!23 = distinct !{!23, !22}
!24 = distinct !{!24, !22}


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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN14FluidBrickGrid21_getNewBrickLocationsER7Array3dI5BrickES3_RS0_IbE(ptr nocapture noundef nonnull readnone align 8 dereferenceable(353) %0, ptr noundef nonnull align 8 dereferenceable(40) %1, ptr noundef nonnull align 8 dereferenceable(40) %2, ptr noundef nonnull align 8 dereferenceable(32) %3) local_unnamed_addr #0 align 2 {
  %5 = getelementptr inbounds i8, ptr %1, i64 8
  %6 = load i32, ptr %5, align 8, !tbaa !5
  %7 = icmp sgt i32 %6, 0
  br i1 %7, label %.preheader28.lr.ph, label %._crit_edge34

.preheader28.lr.ph:                               ; preds = %4
  %8 = getelementptr inbounds i8, ptr %1, i64 4
  %9 = load i32, ptr %8, align 4, !tbaa !14
  %10 = icmp sgt i32 %9, 0
  br i1 %10, label %.preheader28, label %._crit_edge34

.preheader28:                                     ; preds = %.preheader28.lr.ph, %._crit_edge31
  %11 = phi i32 [ %20, %._crit_edge31 ], [ %6, %.preheader28.lr.ph ]
  %12 = phi i32 [ %21, %._crit_edge31 ], [ %9, %.preheader28.lr.ph ]
  %13 = phi i32 [ %22, %._crit_edge31 ], [ %9, %.preheader28.lr.ph ]
  %.032 = phi i32 [ %23, %._crit_edge31 ], [ 0, %.preheader28.lr.ph ]
  %14 = icmp sgt i32 %13, 0
  %15 = load i32, ptr %1, align 8
  %16 = icmp sgt i32 %15, 0
  %or.cond = select i1 %14, i1 %16, i1 false
  br i1 %or.cond, label %.preheader, label %._crit_edge31

._crit_edge34:                                    ; preds = %._crit_edge31, %.preheader28.lr.ph, %4
  ret void

.preheader:                                       ; preds = %.preheader28, %._crit_edge
  %17 = phi i32 [ %25, %._crit_edge ], [ %12, %.preheader28 ]
  %18 = phi i32 [ %26, %._crit_edge ], [ %15, %.preheader28 ]
  %.02330 = phi i32 [ %27, %._crit_edge ], [ 0, %.preheader28 ]
  %19 = icmp sgt i32 %18, 0
  br i1 %19, label %.lr.ph, label %._crit_edge

._crit_edge31.loopexit:                           ; preds = %._crit_edge
  %.pre37 = load i32, ptr %5, align 8, !tbaa !5
  br label %._crit_edge31

._crit_edge31:                                    ; preds = %._crit_edge31.loopexit, %.preheader28
  %20 = phi i32 [ %.pre37, %._crit_edge31.loopexit ], [ %11, %.preheader28 ]
  %21 = phi i32 [ %25, %._crit_edge31.loopexit ], [ %12, %.preheader28 ]
  %22 = phi i32 [ %25, %._crit_edge31.loopexit ], [ %13, %.preheader28 ]
  %23 = add nuw nsw i32 %.032, 1
  %24 = icmp slt i32 %23, %20
  br i1 %24, label %.preheader28, label %._crit_edge34, !llvm.loop !15

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

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

.lr.ph:                                           ; preds = %.preheader, %.critedge
  %.02429 = phi i32 [ %35, %.critedge ], [ 0, %.preheader ]
  %29 = tail call i64 @_ZN7Array3dI5BrickEclEiii(ptr noundef nonnull align 8 dereferenceable(40) %1, i32 noundef %.02429, i32 noundef %.02330, i32 noundef %.032)
  %30 = and i64 %29, 4294967296
  %.not = icmp eq i64 %30, 0
  br i1 %.not, label %31, label %.critedge

31:                                               ; preds = %.lr.ph
  %32 = tail call i64 @_ZN7Array3dI5BrickEclEiii(ptr noundef nonnull align 8 dereferenceable(40) %2, i32 noundef %.02429, i32 noundef %.02330, i32 noundef %.032)
  %33 = and i64 %32, 4294967296
  %.not27 = icmp eq i64 %33, 0
  br i1 %.not27, label %.critedge, label %34

34:                                               ; preds = %31
  tail call void @_ZN7Array3dIbE3setEiiib(ptr noundef nonnull align 8 dereferenceable(32) %3, i32 noundef %.02429, i32 noundef %.02330, i32 noundef %.032, i1 noundef zeroext true)
  br label %.critedge

.critedge:                                        ; preds = %.lr.ph, %31, %34
  %35 = add nuw nsw i32 %.02429, 1
  %36 = load i32, ptr %1, align 8, !tbaa !19
  %37 = icmp slt i32 %35, %36
  br i1 %37, label %.lr.ph, label %._crit_edge.loopexit, !llvm.loop !20
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7Array3dIbE3setEiiib(ptr noundef nonnull align 8 dereferenceable(32), i32 noundef, i32 noundef, i32 noundef, i1 noundef zeroext) 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" }

!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 = !{!"_ZTS7Array3dI5BrickE", !7, i64 0, !7, i64 4, !7, i64 8, !10, i64 16, !11, i64 24, !12, i64 28, !7, i64 36}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"bool", !8, i64 0}
!12 = !{!"_ZTS5Brick", !13, i64 0, !11, i64 4}
!13 = !{!"float", !8, i64 0}
!14 = !{!6, !7, i64 4}
!15 = distinct !{!15, !16, !17}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{!"llvm.loop.unswitch.partial.disable"}
!18 = distinct !{!18, !16, !17}
!19 = !{!6, !7, i64 0}
!20 = distinct !{!20, !16}


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