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

; 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.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }
%struct.GridIndex = type { i32, i32, i32 }
%class.FluidMaterialGrid = type { i32, i32, i32, %class.SubdividedArray3d }
%class.SubdividedArray3d = type { i32, i32, i32, i32, i32, i32, %class.Array3d.1, i32, double }
%class.Array3d.1 = type { i32, i32, i32, ptr, i8, i8, i32 }
%class.ScalarField = type { i32, i32, i32, double, double, double, double, double, double, double, double, i8, [7 x i8], %class.Array3d, %class.Array3d.0, %class.Array3d, %class.Array3d.0, i8, %"class.vmath::vec3" }
%class.Array3d = type <{ i32, i32, i32, [4 x i8], ptr, i8, [3 x i8], float, i32, [4 x i8] }>
%class.Array3d.0 = type { i32, i32, i32, ptr, i8, i8, i32 }
%"class.vmath::vec3" = type { float, float, float }

@_ZSt4cerr = external global %"class.std::basic_ostream", align 8
@.str = external hidden unnamed_addr constant [19 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [108 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [8 x i8], align 1
@__FUNCTION__._ZN11ScalarField15setMaterialGridER15GridIndexVector = external hidden unnamed_addr constant [16 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [85 x i8], align 1

; 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: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) #2

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) #3

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) #4 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_(ptr noundef nonnull align 8 dereferenceable(8)) #2

; Function Attrs: noreturn nounwind
declare void @abort() #5

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN9GridIndexC2Ev(ptr noundef nonnull align 4 dereferenceable(12)) unnamed_addr #6 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7Array3dIbE3setE9GridIndexb(ptr noundef nonnull align 8 dereferenceable(32), i64, i32, i1 noundef zeroext) #4 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN11ScalarField15setMaterialGridER17FluidMaterialGrid(ptr noundef nonnull align 8 dereferenceable(248) %0, ptr noundef nonnull align 8 dereferenceable(88) %1) #4 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca [8 x %struct.GridIndex], align 16
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca %struct.GridIndex, align 4
  %12 = alloca { i64, i32 }, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %13 = load ptr, ptr %3, align 8
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = getelementptr inbounds %class.FluidMaterialGrid, ptr %14, i32 0, i32 0
  %16 = load i32, ptr %15, align 8, !tbaa !9
  %17 = getelementptr inbounds %class.ScalarField, ptr %13, i32 0, i32 0
  %18 = load i32, ptr %17, align 8, !tbaa !17
  %19 = sub nsw i32 %18, 1
  %20 = icmp eq i32 %16, %19
  br i1 %20, label %21, label %37

21:                                               ; preds = %2
  %22 = load ptr, ptr %4, align 8, !tbaa !5
  %23 = getelementptr inbounds %class.FluidMaterialGrid, ptr %22, i32 0, i32 1
  %24 = load i32, ptr %23, align 4, !tbaa !23
  %25 = getelementptr inbounds %class.ScalarField, ptr %13, i32 0, i32 1
  %26 = load i32, ptr %25, align 4, !tbaa !24
  %27 = sub nsw i32 %26, 1
  %28 = icmp eq i32 %24, %27
  br i1 %28, label %29, label %37

29:                                               ; preds = %21
  %30 = load ptr, ptr %4, align 8, !tbaa !5
  %31 = getelementptr inbounds %class.FluidMaterialGrid, ptr %30, i32 0, i32 2
  %32 = load i32, ptr %31, align 8, !tbaa !25
  %33 = getelementptr inbounds %class.ScalarField, ptr %13, i32 0, i32 2
  %34 = load i32, ptr %33, align 8, !tbaa !26
  %35 = sub nsw i32 %34, 1
  %36 = icmp eq i32 %32, %35
  br i1 %36, label %47, label %37

37:                                               ; preds = %29, %21, %2
  %38 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cerr, ptr noundef @.str)
  %39 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %38, ptr noundef @.str.7)
  %40 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %39, ptr noundef @.str.2)
  %41 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %40, ptr noundef @.str.3)
  %42 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %41, ptr noundef @.str.4)
  %43 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %42, ptr noundef @__FUNCTION__._ZN11ScalarField15setMaterialGridER15GridIndexVector)
  %44 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %43, ptr noundef @.str.5)
  %45 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) %44, i32 noundef 340)
  %46 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %45, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  call void @abort() #7
  unreachable

47:                                               ; preds = %29
  call void @llvm.lifetime.start.p0(i64 96, ptr %5) #8
  %48 = getelementptr inbounds [8 x %struct.GridIndex], ptr %5, i32 0, i32 0
  %49 = getelementptr inbounds %struct.GridIndex, ptr %48, i64 8
  br label %50

50:                                               ; preds = %50, %47
  %51 = phi ptr [ %48, %47 ], [ %52, %50 ]
  call void @_ZN9GridIndexC2Ev(ptr noundef nonnull align 4 dereferenceable(12) %51)
  %52 = getelementptr inbounds %struct.GridIndex, ptr %51, i64 1
  %53 = icmp eq ptr %52, %49
  br i1 %53, label %54, label %50

54:                                               ; preds = %50
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #8
  store i32 0, ptr %6, align 4, !tbaa !27
  br label %55

55:                                               ; preds = %115, %54
  %56 = load i32, ptr %6, align 4, !tbaa !27
  %57 = getelementptr inbounds %class.ScalarField, ptr %13, i32 0, i32 2
  %58 = load i32, ptr %57, align 8, !tbaa !26
  %59 = sub nsw i32 %58, 1
  %60 = icmp slt i32 %56, %59
  br i1 %60, label %62, label %61

61:                                               ; preds = %55
  store i32 2, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #8
  br label %118

62:                                               ; preds = %55
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #8
  store i32 0, ptr %8, align 4, !tbaa !27
  br label %63

63:                                               ; preds = %111, %62
  %64 = load i32, ptr %8, align 4, !tbaa !27
  %65 = getelementptr inbounds %class.ScalarField, ptr %13, i32 0, i32 1
  %66 = load i32, ptr %65, align 4, !tbaa !24
  %67 = sub nsw i32 %66, 1
  %68 = icmp slt i32 %64, %67
  br i1 %68, label %70, label %69

69:                                               ; preds = %63
  store i32 5, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #8
  br label %114

70:                                               ; preds = %63
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #8
  store i32 0, ptr %9, align 4, !tbaa !27
  br label %71

71:                                               ; preds = %107, %70
  %72 = load i32, ptr %9, align 4, !tbaa !27
  %73 = getelementptr inbounds %class.ScalarField, ptr %13, i32 0, i32 0
  %74 = load i32, ptr %73, align 8, !tbaa !17
  %75 = sub nsw i32 %74, 1
  %76 = icmp slt i32 %72, %75
  br i1 %76, label %78, label %77

77:                                               ; preds = %71
  store i32 8, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #8
  br label %110

78:                                               ; preds = %71
  %79 = load ptr, ptr %4, align 8, !tbaa !5
  %80 = load i32, ptr %9, align 4, !tbaa !27
  %81 = load i32, ptr %8, align 4, !tbaa !27
  %82 = load i32, ptr %6, align 4, !tbaa !27
  %83 = call noundef zeroext i1 @_ZN17FluidMaterialGrid11isCellSolidEiii(ptr noundef nonnull align 8 dereferenceable(88) %79, i32 noundef %80, i32 noundef %81, i32 noundef %82)
  br i1 %83, label %84, label %106

84:                                               ; preds = %78
  %85 = load i32, ptr %9, align 4, !tbaa !27
  %86 = load i32, ptr %8, align 4, !tbaa !27
  %87 = load i32, ptr %6, align 4, !tbaa !27
  %88 = getelementptr inbounds [8 x %struct.GridIndex], ptr %5, i64 0, i64 0
  call void @_ZN6Grid3d20getGridIndexVerticesEiiiP9GridIndex(i32 noundef %85, i32 noundef %86, i32 noundef %87, ptr noundef %88)
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #8
  store i32 0, ptr %10, align 4, !tbaa !27
  br label %89

89:                                               ; preds = %102, %84
  %90 = load i32, ptr %10, align 4, !tbaa !27
  %91 = icmp slt i32 %90, 8
  br i1 %91, label %93, label %92

92:                                               ; preds = %89
  store i32 11, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #8
  br label %105

93:                                               ; preds = %89
  %94 = getelementptr inbounds %class.ScalarField, ptr %13, i32 0, i32 14
  %95 = load i32, ptr %10, align 4, !tbaa !27
  %96 = sext i32 %95 to i64
  %97 = getelementptr inbounds [8 x %struct.GridIndex], ptr %5, i64 0, i64 %96
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %11, ptr align 4 %97, i64 12, i1 false), !tbaa.struct !28
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %12, ptr align 4 %11, i64 12, i1 false)
  %98 = getelementptr inbounds { i64, i32 }, ptr %12, i32 0, i32 0
  %99 = load i64, ptr %98, align 4
  %100 = getelementptr inbounds { i64, i32 }, ptr %12, i32 0, i32 1
  %101 = load i32, ptr %100, align 4
  call void @_ZN7Array3dIbE3setE9GridIndexb(ptr noundef nonnull align 8 dereferenceable(32) %94, i64 %99, i32 %101, i1 noundef zeroext true)
  br label %102

102:                                              ; preds = %93
  %103 = load i32, ptr %10, align 4, !tbaa !27
  %104 = add nsw i32 %103, 1
  store i32 %104, ptr %10, align 4, !tbaa !27
  br label %89, !llvm.loop !29

105:                                              ; preds = %92
  br label %106

106:                                              ; preds = %105, %78
  br label %107

107:                                              ; preds = %106
  %108 = load i32, ptr %9, align 4, !tbaa !27
  %109 = add nsw i32 %108, 1
  store i32 %109, ptr %9, align 4, !tbaa !27
  br label %71, !llvm.loop !31

110:                                              ; preds = %77
  br label %111

111:                                              ; preds = %110
  %112 = load i32, ptr %8, align 4, !tbaa !27
  %113 = add nsw i32 %112, 1
  store i32 %113, ptr %8, align 4, !tbaa !27
  br label %63, !llvm.loop !32

114:                                              ; preds = %69
  br label %115

115:                                              ; preds = %114
  %116 = load i32, ptr %6, align 4, !tbaa !27
  %117 = add nsw i32 %116, 1
  store i32 %117, ptr %6, align 4, !tbaa !27
  br label %55, !llvm.loop !33

118:                                              ; preds = %61
  call void @llvm.lifetime.end.p0(i64 96, ptr %5) #8
  ret void
}

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN6Grid3d20getGridIndexVerticesEiiiP9GridIndex(i32 noundef, i32 noundef, i32 noundef, ptr noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #5 = { noreturn nounwind "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 #6 = { 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 #7 = { noreturn nounwind }
attributes #8 = { 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, !11, i64 0}
!10 = !{!"_ZTS17FluidMaterialGrid", !11, i64 0, !11, i64 4, !11, i64 8, !12, i64 16}
!11 = !{!"int", !7, i64 0}
!12 = !{!"_ZTS17SubdividedArray3dI8MaterialE", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !13, i64 24, !11, i64 56, !16, i64 64}
!13 = !{!"_ZTS7Array3dI8MaterialE", !11, i64 0, !11, i64 4, !11, i64 8, !6, i64 16, !14, i64 24, !15, i64 25, !11, i64 28}
!14 = !{!"bool", !7, i64 0}
!15 = !{!"_ZTS8Material", !7, i64 0}
!16 = !{!"double", !7, i64 0}
!17 = !{!18, !11, i64 0}
!18 = !{!"_ZTS11ScalarField", !11, i64 0, !11, i64 4, !11, i64 8, !16, i64 16, !16, i64 24, !16, i64 32, !16, i64 40, !16, i64 48, !16, i64 56, !16, i64 64, !16, i64 72, !14, i64 80, !19, i64 88, !21, i64 128, !19, i64 160, !21, i64 200, !14, i64 232, !22, i64 236}
!19 = !{!"_ZTS7Array3dIfE", !11, i64 0, !11, i64 4, !11, i64 8, !6, i64 16, !14, i64 24, !20, i64 28, !11, i64 32}
!20 = !{!"float", !7, i64 0}
!21 = !{!"_ZTS7Array3dIbE", !11, i64 0, !11, i64 4, !11, i64 8, !6, i64 16, !14, i64 24, !14, i64 25, !11, i64 28}
!22 = !{!"_ZTSN5vmath4vec3E", !20, i64 0, !20, i64 4, !20, i64 8}
!23 = !{!10, !11, i64 4}
!24 = !{!18, !11, i64 4}
!25 = !{!10, !11, i64 8}
!26 = !{!18, !11, i64 8}
!27 = !{!11, !11, i64 0}
!28 = !{i64 0, i64 4, !27, i64 4, i64 4, !27, i64 8, i64 4, !27}
!29 = distinct !{!29, !30}
!30 = !{!"llvm.loop.mustprogress"}
!31 = distinct !{!31, !30}
!32 = distinct !{!32, !30}
!33 = distinct !{!33, !30}


; 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.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }
%struct.GridIndex = type { i32, i32, i32 }

@_ZSt4cerr = external global %"class.std::basic_ostream", align 8
@.str = external hidden unnamed_addr constant [19 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [108 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [8 x i8], align 1
@__FUNCTION__._ZN11ScalarField15setMaterialGridER15GridIndexVector = external hidden unnamed_addr constant [16 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [85 x i8], align 1

; 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: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) local_unnamed_addr #1

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) local_unnamed_addr #3 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_(ptr noundef nonnull align 8 dereferenceable(8)) #1

; Function Attrs: noreturn nounwind
declare void @abort() local_unnamed_addr #4

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN9GridIndexC2Ev(ptr noundef nonnull align 4 dereferenceable(12)) unnamed_addr #5 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7Array3dIbE3setE9GridIndexb(ptr noundef nonnull align 8 dereferenceable(32), i64, i32, i1 noundef zeroext) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN11ScalarField15setMaterialGridER17FluidMaterialGrid(ptr noundef nonnull align 8 dereferenceable(248) %0, ptr noundef nonnull align 8 dereferenceable(88) %1) local_unnamed_addr #3 align 2 {
  %3 = alloca [8 x %struct.GridIndex], align 16
  %4 = load i32, ptr %1, align 8, !tbaa !5
  %5 = load i32, ptr %0, align 8, !tbaa !16
  %6 = add nsw i32 %5, -1
  %7 = icmp eq i32 %4, %6
  br i1 %7, label %8, label %22

8:                                                ; preds = %2
  %9 = getelementptr inbounds i8, ptr %1, i64 4
  %10 = load i32, ptr %9, align 4, !tbaa !22
  %11 = getelementptr inbounds i8, ptr %0, i64 4
  %12 = load i32, ptr %11, align 4, !tbaa !23
  %13 = add nsw i32 %12, -1
  %14 = icmp eq i32 %10, %13
  br i1 %14, label %15, label %22

15:                                               ; preds = %8
  %16 = getelementptr inbounds i8, ptr %1, i64 8
  %17 = load i32, ptr %16, align 8, !tbaa !24
  %18 = getelementptr inbounds i8, ptr %0, i64 8
  %19 = load i32, ptr %18, align 8, !tbaa !25
  %20 = add nsw i32 %19, -1
  %21 = icmp eq i32 %17, %20
  br i1 %21, label %.preheader26, label %22

22:                                               ; preds = %15, %8, %2
  %23 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cerr, ptr noundef nonnull @.str)
  %24 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %23, ptr noundef nonnull @.str.7)
  %25 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %24, ptr noundef nonnull @.str.2)
  %26 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %25, ptr noundef nonnull @.str.3)
  %27 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %26, ptr noundef nonnull @.str.4)
  %28 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %27, ptr noundef nonnull @__FUNCTION__._ZN11ScalarField15setMaterialGridER15GridIndexVector)
  %29 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %28, ptr noundef nonnull @.str.5)
  %30 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) %29, i32 noundef 340)
  %31 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %30, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  tail call void @abort() #6
  unreachable

.preheader26:                                     ; preds = %15
  call void @llvm.lifetime.start.p0(i64 96, ptr nonnull %3) #7
  call void @_ZN9GridIndexC2Ev(ptr noundef nonnull align 4 dereferenceable(12) %3)
  %.ptr.1 = getelementptr inbounds i8, ptr %3, i64 12
  call void @_ZN9GridIndexC2Ev(ptr noundef nonnull align 4 dereferenceable(12) %.ptr.1)
  %.ptr.2 = getelementptr inbounds i8, ptr %3, i64 24
  call void @_ZN9GridIndexC2Ev(ptr noundef nonnull align 4 dereferenceable(12) %.ptr.2)
  %.ptr.3 = getelementptr inbounds i8, ptr %3, i64 36
  call void @_ZN9GridIndexC2Ev(ptr noundef nonnull align 4 dereferenceable(12) %.ptr.3)
  %.ptr.4 = getelementptr inbounds i8, ptr %3, i64 48
  call void @_ZN9GridIndexC2Ev(ptr noundef nonnull align 4 dereferenceable(12) %.ptr.4)
  %.ptr.5 = getelementptr inbounds i8, ptr %3, i64 60
  call void @_ZN9GridIndexC2Ev(ptr noundef nonnull align 4 dereferenceable(12) %.ptr.5)
  %.ptr.6 = getelementptr inbounds i8, ptr %3, i64 72
  call void @_ZN9GridIndexC2Ev(ptr noundef nonnull align 4 dereferenceable(12) %.ptr.6)
  %.ptr.7 = getelementptr inbounds i8, ptr %3, i64 84
  call void @_ZN9GridIndexC2Ev(ptr noundef nonnull align 4 dereferenceable(12) %.ptr.7)
  %32 = load i32, ptr %18, align 8, !tbaa !25
  %33 = icmp sgt i32 %32, 1
  br i1 %33, label %.preheader25.lr.ph, label %._crit_edge33

.preheader25.lr.ph:                               ; preds = %.preheader26
  %34 = getelementptr inbounds i8, ptr %0, i64 128
  %35 = load i32, ptr %11, align 4, !tbaa !23
  %36 = icmp sgt i32 %35, 1
  br i1 %36, label %.preheader25.preheader, label %._crit_edge33

.preheader25.preheader:                           ; preds = %.preheader25.lr.ph
  %.sroa.22.0..sroa_idx = getelementptr inbounds i8, ptr %3, i64 8
  %.sroa.22.0..sroa_idx.1 = getelementptr inbounds i8, ptr %3, i64 20
  %.sroa.22.0..sroa_idx.2 = getelementptr inbounds i8, ptr %3, i64 32
  %.sroa.22.0..sroa_idx.3 = getelementptr inbounds i8, ptr %3, i64 44
  %.sroa.22.0..sroa_idx.4 = getelementptr inbounds i8, ptr %3, i64 56
  %.sroa.22.0..sroa_idx.5 = getelementptr inbounds i8, ptr %3, i64 68
  %.sroa.22.0..sroa_idx.6 = getelementptr inbounds i8, ptr %3, i64 80
  %.sroa.22.0..sroa_idx.7 = getelementptr inbounds i8, ptr %3, i64 92
  br label %.preheader25

.preheader25:                                     ; preds = %.preheader25.preheader, %._crit_edge30
  %37 = phi i32 [ %46, %._crit_edge30 ], [ %32, %.preheader25.preheader ]
  %38 = phi i32 [ %47, %._crit_edge30 ], [ %35, %.preheader25.preheader ]
  %39 = phi i32 [ %48, %._crit_edge30 ], [ %35, %.preheader25.preheader ]
  %.031 = phi i32 [ %49, %._crit_edge30 ], [ 0, %.preheader25.preheader ]
  %40 = icmp sgt i32 %39, 1
  %41 = load i32, ptr %0, align 8
  %42 = icmp sgt i32 %41, 1
  %or.cond = select i1 %40, i1 %42, i1 false
  br i1 %or.cond, label %.preheader, label %._crit_edge30

._crit_edge33:                                    ; preds = %._crit_edge30, %.preheader25.lr.ph, %.preheader26
  call void @llvm.lifetime.end.p0(i64 96, ptr nonnull %3) #7
  ret void

.preheader:                                       ; preds = %.preheader25, %._crit_edge
  %43 = phi i32 [ %52, %._crit_edge ], [ %38, %.preheader25 ]
  %44 = phi i32 [ %53, %._crit_edge ], [ %41, %.preheader25 ]
  %.02129 = phi i32 [ %54, %._crit_edge ], [ 0, %.preheader25 ]
  %45 = icmp sgt i32 %44, 1
  br i1 %45, label %.lr.ph, label %._crit_edge

._crit_edge30.loopexit:                           ; preds = %._crit_edge
  %.pre37 = load i32, ptr %18, align 8, !tbaa !25
  br label %._crit_edge30

._crit_edge30:                                    ; preds = %._crit_edge30.loopexit, %.preheader25
  %46 = phi i32 [ %.pre37, %._crit_edge30.loopexit ], [ %37, %.preheader25 ]
  %47 = phi i32 [ %52, %._crit_edge30.loopexit ], [ %38, %.preheader25 ]
  %48 = phi i32 [ %52, %._crit_edge30.loopexit ], [ %39, %.preheader25 ]
  %49 = add nuw nsw i32 %.031, 1
  %50 = add nsw i32 %46, -1
  %51 = icmp slt i32 %49, %50
  br i1 %51, label %.preheader25, label %._crit_edge33, !llvm.loop !26

._crit_edge.loopexit:                             ; preds = %.loopexit
  %.pre = load i32, ptr %11, align 4, !tbaa !23
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %.preheader
  %52 = phi i32 [ %.pre, %._crit_edge.loopexit ], [ %43, %.preheader ]
  %53 = phi i32 [ %59, %._crit_edge.loopexit ], [ %44, %.preheader ]
  %54 = add nuw nsw i32 %.02129, 1
  %55 = add nsw i32 %52, -1
  %56 = icmp slt i32 %54, %55
  br i1 %56, label %.preheader, label %._crit_edge30.loopexit, !llvm.loop !29

.lr.ph:                                           ; preds = %.preheader, %.loopexit
  %.02228 = phi i32 [ %58, %.loopexit ], [ 0, %.preheader ]
  %57 = call noundef zeroext i1 @_ZN17FluidMaterialGrid11isCellSolidEiii(ptr noundef nonnull align 8 dereferenceable(88) %1, i32 noundef %.02228, i32 noundef %.02129, i32 noundef %.031)
  br i1 %57, label %.loopexit.loopexit, label %.loopexit

.loopexit.loopexit:                               ; preds = %.lr.ph
  call void @_ZN6Grid3d20getGridIndexVerticesEiiiP9GridIndex(i32 noundef %.02228, i32 noundef %.02129, i32 noundef %.031, ptr noundef nonnull %3)
  %.sroa.01.0.copyload = load i64, ptr %3, align 16
  %.sroa.22.0.copyload = load i32, ptr %.sroa.22.0..sroa_idx, align 8, !tbaa !30
  call void @_ZN7Array3dIbE3setE9GridIndexb(ptr noundef nonnull align 8 dereferenceable(32) %34, i64 %.sroa.01.0.copyload, i32 %.sroa.22.0.copyload, i1 noundef zeroext true)
  %.sroa.01.0.copyload.1 = load i64, ptr %.ptr.1, align 4
  %.sroa.22.0.copyload.1 = load i32, ptr %.sroa.22.0..sroa_idx.1, align 4, !tbaa !30
  call void @_ZN7Array3dIbE3setE9GridIndexb(ptr noundef nonnull align 8 dereferenceable(32) %34, i64 %.sroa.01.0.copyload.1, i32 %.sroa.22.0.copyload.1, i1 noundef zeroext true)
  %.sroa.01.0.copyload.2 = load i64, ptr %.ptr.2, align 8
  %.sroa.22.0.copyload.2 = load i32, ptr %.sroa.22.0..sroa_idx.2, align 16, !tbaa !30
  call void @_ZN7Array3dIbE3setE9GridIndexb(ptr noundef nonnull align 8 dereferenceable(32) %34, i64 %.sroa.01.0.copyload.2, i32 %.sroa.22.0.copyload.2, i1 noundef zeroext true)
  %.sroa.01.0.copyload.3 = load i64, ptr %.ptr.3, align 4
  %.sroa.22.0.copyload.3 = load i32, ptr %.sroa.22.0..sroa_idx.3, align 4, !tbaa !30
  call void @_ZN7Array3dIbE3setE9GridIndexb(ptr noundef nonnull align 8 dereferenceable(32) %34, i64 %.sroa.01.0.copyload.3, i32 %.sroa.22.0.copyload.3, i1 noundef zeroext true)
  %.sroa.01.0.copyload.4 = load i64, ptr %.ptr.4, align 16
  %.sroa.22.0.copyload.4 = load i32, ptr %.sroa.22.0..sroa_idx.4, align 8, !tbaa !30
  call void @_ZN7Array3dIbE3setE9GridIndexb(ptr noundef nonnull align 8 dereferenceable(32) %34, i64 %.sroa.01.0.copyload.4, i32 %.sroa.22.0.copyload.4, i1 noundef zeroext true)
  %.sroa.01.0.copyload.5 = load i64, ptr %.ptr.5, align 4
  %.sroa.22.0.copyload.5 = load i32, ptr %.sroa.22.0..sroa_idx.5, align 4, !tbaa !30
  call void @_ZN7Array3dIbE3setE9GridIndexb(ptr noundef nonnull align 8 dereferenceable(32) %34, i64 %.sroa.01.0.copyload.5, i32 %.sroa.22.0.copyload.5, i1 noundef zeroext true)
  %.sroa.01.0.copyload.6 = load i64, ptr %.ptr.6, align 8
  %.sroa.22.0.copyload.6 = load i32, ptr %.sroa.22.0..sroa_idx.6, align 16, !tbaa !30
  call void @_ZN7Array3dIbE3setE9GridIndexb(ptr noundef nonnull align 8 dereferenceable(32) %34, i64 %.sroa.01.0.copyload.6, i32 %.sroa.22.0.copyload.6, i1 noundef zeroext true)
  %.sroa.01.0.copyload.7 = load i64, ptr %.ptr.7, align 4
  %.sroa.22.0.copyload.7 = load i32, ptr %.sroa.22.0..sroa_idx.7, align 4, !tbaa !30
  call void @_ZN7Array3dIbE3setE9GridIndexb(ptr noundef nonnull align 8 dereferenceable(32) %34, i64 %.sroa.01.0.copyload.7, i32 %.sroa.22.0.copyload.7, i1 noundef zeroext true)
  br label %.loopexit

.loopexit:                                        ; preds = %.loopexit.loopexit, %.lr.ph
  %58 = add nuw nsw i32 %.02228, 1
  %59 = load i32, ptr %0, align 8, !tbaa !16
  %60 = add nsw i32 %59, -1
  %61 = icmp slt i32 %58, %60
  br i1 %61, label %.lr.ph, label %._crit_edge.loopexit, !llvm.loop !31
}

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN6Grid3d20getGridIndexVerticesEiiiP9GridIndex(i32 noundef, i32 noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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" }
attributes #3 = { 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 #4 = { noreturn nounwind "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 #5 = { 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 #6 = { noreturn nounwind }
attributes #7 = { 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, !7, i64 0}
!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 = !{!17, !7, i64 0}
!17 = !{!"_ZTS11ScalarField", !7, i64 0, !7, i64 4, !7, i64 8, !15, i64 16, !15, i64 24, !15, i64 32, !15, i64 40, !15, i64 48, !15, i64 56, !15, i64 64, !15, i64 72, !13, i64 80, !18, i64 88, !20, i64 128, !18, i64 160, !20, i64 200, !13, i64 232, !21, i64 236}
!18 = !{!"_ZTS7Array3dIfE", !7, i64 0, !7, i64 4, !7, i64 8, !12, i64 16, !13, i64 24, !19, i64 28, !7, i64 32}
!19 = !{!"float", !8, i64 0}
!20 = !{!"_ZTS7Array3dIbE", !7, i64 0, !7, i64 4, !7, i64 8, !12, i64 16, !13, i64 24, !13, i64 25, !7, i64 28}
!21 = !{!"_ZTSN5vmath4vec3E", !19, i64 0, !19, i64 4, !19, i64 8}
!22 = !{!6, !7, i64 4}
!23 = !{!17, !7, i64 4}
!24 = !{!6, !7, i64 8}
!25 = !{!17, !7, i64 8}
!26 = distinct !{!26, !27, !28}
!27 = !{!"llvm.loop.mustprogress"}
!28 = !{!"llvm.loop.unswitch.partial.disable"}
!29 = distinct !{!29, !27, !28}
!30 = !{!7, !7, i64 0}
!31 = distinct !{!31, !27}


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