; LLVM IR from niessner/Matterport :: code/gaps/pkgs/R3Shapes/R3Grid.ll (ZNK6R3Grid5SliceEii)

; 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.R3Box = type { %class.R3Solid, %class.R3Point, %class.R3Point }
%class.R3Solid = type { %class.R3Shape }
%class.R3Shape = type { ptr }
%class.R3Point = type { [3 x double] }
%class.R2Box = type { %class.R2Solid, %class.R2Point, %class.R2Point }
%class.R2Solid = type { %class.R2Shape }
%class.R2Shape = type { ptr }
%class.R2Point = type { [2 x double] }
%class.R3Grid = type { %class.R3Affine, %class.R3Affine, double, double, ptr, [3 x i32], i32, i32, i32 }
%class.R3Affine = type { %class.R3Transformation, %class.R4Matrix, %class.R4Matrix, %class.RNFlags }
%class.R3Transformation = type { ptr }
%class.R4Matrix = type { [4 x [4 x double]] }
%class.RNFlags = type { i64 }

@stderr = external global ptr, align 8
@.str.9 = external hidden unnamed_addr constant [26 x i8], align 1

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: inlinehint mustprogress uwtable
declare dso_local noundef double @_ZNK6R3Grid9GridValueEiii(ptr noundef nonnull align 8 dereferenceable(592), i32 noundef, i32 noundef, i32 noundef) #1 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZN7R3PointixEi(ptr noundef nonnull align 8 dereferenceable(24), i32 noundef) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZNK6R3Grid5SliceEii(ptr noundef nonnull align 8 dereferenceable(592) %0, i32 noundef %1, i32 noundef %2) #2 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca %class.R3Box, align 8
  %11 = alloca %class.R2Box, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  %14 = alloca ptr, align 8
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca double, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store i32 %2, ptr %7, align 4, !tbaa !9
  %19 = load ptr, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #8
  %20 = load i32, ptr %6, align 4, !tbaa !9
  %21 = add nsw i32 %20, 1
  %22 = srem i32 %21, 3
  store i32 %22, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #8
  %23 = load i32, ptr %6, align 4, !tbaa !9
  %24 = add nsw i32 %23, 2
  %25 = srem i32 %24, 3
  store i32 %25, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 56, ptr %10) #8
  call void @_ZNK6R3Grid8WorldBoxEv(ptr dead_on_unwind writable sret(%class.R3Box) align 8 %10, ptr noundef nonnull align 8 dereferenceable(592) %19)
  call void @llvm.lifetime.start.p0(i64 40, ptr %11) #8
  %26 = invoke noundef nonnull align 8 dereferenceable(24) ptr @_ZN5R3BoxixEi(ptr noundef nonnull align 8 dereferenceable(56) %10, i32 noundef 0)
          to label %27 unwind label %69

27:                                               ; preds = %3
  %28 = load i32, ptr %8, align 4, !tbaa !9
  %29 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZN7R3PointixEi(ptr noundef nonnull align 8 dereferenceable(24) %26, i32 noundef %28)
          to label %30 unwind label %69

30:                                               ; preds = %27
  %31 = load double, ptr %29, align 8, !tbaa !11
  %32 = invoke noundef nonnull align 8 dereferenceable(24) ptr @_ZN5R3BoxixEi(ptr noundef nonnull align 8 dereferenceable(56) %10, i32 noundef 0)
          to label %33 unwind label %69

33:                                               ; preds = %30
  %34 = load i32, ptr %9, align 4, !tbaa !9
  %35 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZN7R3PointixEi(ptr noundef nonnull align 8 dereferenceable(24) %32, i32 noundef %34)
          to label %36 unwind label %69

36:                                               ; preds = %33
  %37 = load double, ptr %35, align 8, !tbaa !11
  %38 = invoke noundef nonnull align 8 dereferenceable(24) ptr @_ZN5R3BoxixEi(ptr noundef nonnull align 8 dereferenceable(56) %10, i32 noundef 1)
          to label %39 unwind label %69

39:                                               ; preds = %36
  %40 = load i32, ptr %8, align 4, !tbaa !9
  %41 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZN7R3PointixEi(ptr noundef nonnull align 8 dereferenceable(24) %38, i32 noundef %40)
          to label %42 unwind label %69

42:                                               ; preds = %39
  %43 = load double, ptr %41, align 8, !tbaa !11
  %44 = invoke noundef nonnull align 8 dereferenceable(24) ptr @_ZN5R3BoxixEi(ptr noundef nonnull align 8 dereferenceable(56) %10, i32 noundef 1)
          to label %45 unwind label %69

45:                                               ; preds = %42
  %46 = load i32, ptr %9, align 4, !tbaa !9
  %47 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZN7R3PointixEi(ptr noundef nonnull align 8 dereferenceable(24) %44, i32 noundef %46)
          to label %48 unwind label %69

48:                                               ; preds = %45
  %49 = load double, ptr %47, align 8, !tbaa !11
  invoke void @_ZN5R2BoxC1Edddd(ptr noundef nonnull align 8 dereferenceable(40) %11, double noundef %31, double noundef %37, double noundef %43, double noundef %49)
          to label %50 unwind label %69

50:                                               ; preds = %48
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #8
  %51 = invoke noalias noundef nonnull ptr @_Znwm(i64 noundef 208) #9
          to label %52 unwind label %73

52:                                               ; preds = %50
  %53 = getelementptr inbounds %class.R3Grid, ptr %19, i32 0, i32 5
  %54 = load i32, ptr %8, align 4, !tbaa !9
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds [3 x i32], ptr %53, i64 0, i64 %55
  %57 = load i32, ptr %56, align 4, !tbaa !9
  %58 = getelementptr inbounds %class.R3Grid, ptr %19, i32 0, i32 5
  %59 = load i32, ptr %9, align 4, !tbaa !9
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds [3 x i32], ptr %58, i64 0, i64 %60
  %62 = load i32, ptr %61, align 4, !tbaa !9
  invoke void @_ZN6R2GridC1EiiRK5R2Box(ptr noundef nonnull align 8 dereferenceable(208) %51, i32 noundef %57, i32 noundef %62, ptr noundef nonnull align 8 dereferenceable(40) %11)
          to label %63 unwind label %77

63:                                               ; preds = %52
  store ptr %51, ptr %14, align 8, !tbaa !5
  %64 = load ptr, ptr %14, align 8, !tbaa !5
  %65 = icmp ne ptr %64, null
  br i1 %65, label %81, label %66

66:                                               ; preds = %63
  %67 = load ptr, ptr @stderr, align 8, !tbaa !5
  %68 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %67, ptr noundef @.str.9) #8
  store ptr null, ptr %4, align 8
  store i32 1, ptr %15, align 4
  br label %145

69:                                               ; preds = %48, %45, %42, %39, %36, %33, %30, %27, %3
  %70 = landingpad { ptr, i32 }
          cleanup
  %71 = extractvalue { ptr, i32 } %70, 0
  store ptr %71, ptr %12, align 8
  %72 = extractvalue { ptr, i32 } %70, 1
  store i32 %72, ptr %13, align 4
  br label %148

73:                                               ; preds = %50
  %74 = landingpad { ptr, i32 }
          cleanup
  %75 = extractvalue { ptr, i32 } %74, 0
  store ptr %75, ptr %12, align 8
  %76 = extractvalue { ptr, i32 } %74, 1
  store i32 %76, ptr %13, align 4
  br label %147

77:                                               ; preds = %52
  %78 = landingpad { ptr, i32 }
          cleanup
  %79 = extractvalue { ptr, i32 } %78, 0
  store ptr %79, ptr %12, align 8
  %80 = extractvalue { ptr, i32 } %78, 1
  store i32 %80, ptr %13, align 4
  call void @_ZdlPvm(ptr noundef %51, i64 noundef 208) #10
  br label %147

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

82:                                               ; preds = %140, %81
  %83 = load i32, ptr %16, align 4, !tbaa !9
  %84 = getelementptr inbounds %class.R3Grid, ptr %19, i32 0, i32 5
  %85 = load i32, ptr %8, align 4, !tbaa !9
  %86 = sext i32 %85 to i64
  %87 = getelementptr inbounds [3 x i32], ptr %84, i64 0, i64 %86
  %88 = load i32, ptr %87, align 4, !tbaa !9
  %89 = icmp slt i32 %83, %88
  br i1 %89, label %91, label %90

90:                                               ; preds = %82
  store i32 2, ptr %15, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #8
  br label %143

91:                                               ; preds = %82
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #8
  store i32 0, ptr %17, align 4, !tbaa !9
  br label %92

92:                                               ; preds = %136, %91
  %93 = load i32, ptr %17, align 4, !tbaa !9
  %94 = getelementptr inbounds %class.R3Grid, ptr %19, i32 0, i32 5
  %95 = load i32, ptr %9, align 4, !tbaa !9
  %96 = sext i32 %95 to i64
  %97 = getelementptr inbounds [3 x i32], ptr %94, i64 0, i64 %96
  %98 = load i32, ptr %97, align 4, !tbaa !9
  %99 = icmp slt i32 %93, %98
  br i1 %99, label %101, label %100

100:                                              ; preds = %92
  store i32 5, ptr %15, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #8
  br label %139

101:                                              ; preds = %92
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #8
  store double 0.000000e+00, ptr %18, align 8, !tbaa !11
  %102 = load i32, ptr %6, align 4, !tbaa !9
  %103 = icmp eq i32 %102, 0
  br i1 %103, label %104, label %114

104:                                              ; preds = %101
  %105 = load i32, ptr %7, align 4, !tbaa !9
  %106 = load i32, ptr %16, align 4, !tbaa !9
  %107 = load i32, ptr %17, align 4, !tbaa !9
  %108 = invoke noundef double @_ZNK6R3Grid9GridValueEiii(ptr noundef nonnull align 8 dereferenceable(592) %19, i32 noundef %105, i32 noundef %106, i32 noundef %107)
          to label %109 unwind label %110

109:                                              ; preds = %104
  store double %108, ptr %18, align 8, !tbaa !11
  br label %130

110:                                              ; preds = %130, %123, %117, %104
  %111 = landingpad { ptr, i32 }
          cleanup
  %112 = extractvalue { ptr, i32 } %111, 0
  store ptr %112, ptr %12, align 8
  %113 = extractvalue { ptr, i32 } %111, 1
  store i32 %113, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #8
  br label %147

114:                                              ; preds = %101
  %115 = load i32, ptr %6, align 4, !tbaa !9
  %116 = icmp eq i32 %115, 1
  br i1 %116, label %117, label %123

117:                                              ; preds = %114
  %118 = load i32, ptr %17, align 4, !tbaa !9
  %119 = load i32, ptr %7, align 4, !tbaa !9
  %120 = load i32, ptr %16, align 4, !tbaa !9
  %121 = invoke noundef double @_ZNK6R3Grid9GridValueEiii(ptr noundef nonnull align 8 dereferenceable(592) %19, i32 noundef %118, i32 noundef %119, i32 noundef %120)
          to label %122 unwind label %110

122:                                              ; preds = %117
  store double %121, ptr %18, align 8, !tbaa !11
  br label %129

123:                                              ; preds = %114
  %124 = load i32, ptr %16, align 4, !tbaa !9
  %125 = load i32, ptr %17, align 4, !tbaa !9
  %126 = load i32, ptr %7, align 4, !tbaa !9
  %127 = invoke noundef double @_ZNK6R3Grid9GridValueEiii(ptr noundef nonnull align 8 dereferenceable(592) %19, i32 noundef %124, i32 noundef %125, i32 noundef %126)
          to label %128 unwind label %110

128:                                              ; preds = %123
  store double %127, ptr %18, align 8, !tbaa !11
  br label %129

129:                                              ; preds = %128, %122
  br label %130

130:                                              ; preds = %129, %109
  %131 = load ptr, ptr %14, align 8, !tbaa !5
  %132 = load i32, ptr %16, align 4, !tbaa !9
  %133 = load i32, ptr %17, align 4, !tbaa !9
  %134 = load double, ptr %18, align 8, !tbaa !11
  invoke void @_ZN6R2Grid12SetGridValueEiid(ptr noundef nonnull align 8 dereferenceable(208) %131, i32 noundef %132, i32 noundef %133, double noundef %134)
          to label %135 unwind label %110

135:                                              ; preds = %130
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #8
  br label %136

136:                                              ; preds = %135
  %137 = load i32, ptr %17, align 4, !tbaa !9
  %138 = add nsw i32 %137, 1
  store i32 %138, ptr %17, align 4, !tbaa !9
  br label %92, !llvm.loop !13

139:                                              ; preds = %100
  br label %140

140:                                              ; preds = %139
  %141 = load i32, ptr %16, align 4, !tbaa !9
  %142 = add nsw i32 %141, 1
  store i32 %142, ptr %16, align 4, !tbaa !9
  br label %82, !llvm.loop !15

143:                                              ; preds = %90
  %144 = load ptr, ptr %14, align 8, !tbaa !5
  store ptr %144, ptr %4, align 8
  store i32 1, ptr %15, align 4
  br label %145

145:                                              ; preds = %143, %66
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #8
  call void @_ZN7R2SolidD2Ev(ptr noundef nonnull align 8 dereferenceable(40) %11) #8
  call void @llvm.lifetime.end.p0(i64 40, ptr %11) #8
  call void @_ZN7R3SolidD2Ev(ptr noundef nonnull align 8 dereferenceable(56) %10) #8
  call void @llvm.lifetime.end.p0(i64 56, ptr %10) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #8
  %146 = load ptr, ptr %4, align 8
  ret ptr %146

147:                                              ; preds = %110, %77, %73
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #8
  call void @_ZN7R2SolidD2Ev(ptr noundef nonnull align 8 dereferenceable(40) %11) #8
  br label %148

148:                                              ; preds = %147, %69
  call void @llvm.lifetime.end.p0(i64 40, ptr %11) #8
  call void @_ZN7R3SolidD2Ev(ptr noundef nonnull align 8 dereferenceable(56) %10) #8
  call void @llvm.lifetime.end.p0(i64 56, ptr %10) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #8
  br label %149

149:                                              ; preds = %148
  %150 = load ptr, ptr %12, align 8
  %151 = load i32, ptr %13, align 4
  %152 = insertvalue { ptr, i32 } poison, ptr %150, 0
  %153 = insertvalue { ptr, i32 } %152, i32 %151, 1
  resume { ptr, i32 } %153
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZNK6R3Grid8WorldBoxEv(ptr dead_on_unwind noalias writable sret(%class.R3Box) align 8, ptr noundef nonnull align 8 dereferenceable(592)) #1 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(24) ptr @_ZN5R3BoxixEi(ptr noundef nonnull align 8 dereferenceable(56), i32 noundef) #3 align 2

declare void @_ZN5R2BoxC1Edddd(ptr noundef nonnull align 8 dereferenceable(40), double noundef, double noundef, double noundef, double noundef) unnamed_addr #4

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) #5

declare void @_ZN6R2GridC1EiiRK5R2Box(ptr noundef nonnull align 8 dereferenceable(208), i32 noundef, i32 noundef, ptr noundef nonnull align 8 dereferenceable(40)) unnamed_addr #4

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) #6

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #7

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN6R2Grid12SetGridValueEiid(ptr noundef nonnull align 8 dereferenceable(208), i32 noundef, i32 noundef, double noundef) #1 align 2

; Function Attrs: nounwind
declare void @_ZN7R2SolidD2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #7

; Function Attrs: nounwind
declare void @_ZN7R3SolidD2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #7

attributes #0 = { 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 = { 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 = { inlinehint 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 #4 = { "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 = { nobuiltin allocsize(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 = { nobuiltin 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 #7 = { 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 #8 = { nounwind }
attributes #9 = { builtin allocsize(0) }
attributes #10 = { builtin 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, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}


; 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.R3Box = type { %class.R3Solid, %class.R3Point, %class.R3Point }
%class.R3Solid = type { %class.R3Shape }
%class.R3Shape = type { ptr }
%class.R3Point = type { [3 x double] }
%class.R2Box = type { %class.R2Solid, %class.R2Point, %class.R2Point }
%class.R2Solid = type { %class.R2Shape }
%class.R2Shape = type { ptr }
%class.R2Point = type { [2 x double] }

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: inlinehint mustprogress uwtable
declare dso_local noundef double @_ZNK6R3Grid9GridValueEiii(ptr noundef nonnull align 8 dereferenceable(592), i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZN7R3PointixEi(ptr noundef nonnull align 8 dereferenceable(24), i32 noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef nonnull ptr @_ZNK6R3Grid5SliceEii(ptr noundef nonnull align 8 dereferenceable(592) %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #2 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca %class.R3Box, align 8
  %5 = alloca %class.R2Box, align 8
  %6 = add nsw i32 %1, 1
  %7 = srem i32 %6, 3
  %8 = add nsw i32 %1, 2
  %9 = srem i32 %8, 3
  call void @llvm.lifetime.start.p0(i64 56, ptr nonnull %4) #8
  call void @_ZNK6R3Grid8WorldBoxEv(ptr dead_on_unwind nonnull writable sret(%class.R3Box) align 8 %4, ptr noundef nonnull align 8 dereferenceable(592) %0)
  call void @llvm.lifetime.start.p0(i64 40, ptr nonnull %5) #8
  %10 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZN5R3BoxixEi(ptr noundef nonnull align 8 dereferenceable(56) %4, i32 noundef 0)
  %11 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZN7R3PointixEi(ptr noundef nonnull align 8 dereferenceable(24) %10, i32 noundef %7)
          to label %12 unwind label %40

12:                                               ; preds = %3
  %13 = load double, ptr %11, align 8, !tbaa !5
  %14 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZN5R3BoxixEi(ptr noundef nonnull align 8 dereferenceable(56) %4, i32 noundef 0)
  %15 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZN7R3PointixEi(ptr noundef nonnull align 8 dereferenceable(24) %14, i32 noundef %9)
          to label %16 unwind label %40

16:                                               ; preds = %12
  %17 = load double, ptr %15, align 8, !tbaa !5
  %18 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZN5R3BoxixEi(ptr noundef nonnull align 8 dereferenceable(56) %4, i32 noundef 1)
  %19 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZN7R3PointixEi(ptr noundef nonnull align 8 dereferenceable(24) %18, i32 noundef %7)
          to label %20 unwind label %40

20:                                               ; preds = %16
  %21 = load double, ptr %19, align 8, !tbaa !5
  %22 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZN5R3BoxixEi(ptr noundef nonnull align 8 dereferenceable(56) %4, i32 noundef 1)
  %23 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZN7R3PointixEi(ptr noundef nonnull align 8 dereferenceable(24) %22, i32 noundef %9)
          to label %24 unwind label %40

24:                                               ; preds = %20
  %25 = load double, ptr %23, align 8, !tbaa !5
  invoke void @_ZN5R2BoxC1Edddd(ptr noundef nonnull align 8 dereferenceable(40) %5, double noundef %13, double noundef %17, double noundef %21, double noundef %25)
          to label %26 unwind label %40

26:                                               ; preds = %24
  %27 = invoke noalias noundef nonnull dereferenceable(208) ptr @_Znwm(i64 noundef 208) #9
          to label %28 unwind label %42

28:                                               ; preds = %26
  %29 = getelementptr inbounds i8, ptr %0, i64 568
  %30 = sext i32 %7 to i64
  %31 = getelementptr inbounds [3 x i32], ptr %29, i64 0, i64 %30
  %32 = load i32, ptr %31, align 4, !tbaa !9
  %33 = sext i32 %9 to i64
  %34 = getelementptr inbounds [3 x i32], ptr %29, i64 0, i64 %33
  %35 = load i32, ptr %34, align 4, !tbaa !9
  invoke void @_ZN6R2GridC1EiiRK5R2Box(ptr noundef nonnull align 8 dereferenceable(208) %27, i32 noundef %32, i32 noundef %35, ptr noundef nonnull align 8 dereferenceable(40) %5)
          to label %.preheader43 unwind label %44

.preheader43:                                     ; preds = %28
  %36 = load i32, ptr %31, align 4, !tbaa !9
  %37 = icmp sgt i32 %36, 0
  br i1 %37, label %.preheader.lr.ph, label %._crit_edge52

.preheader.lr.ph:                                 ; preds = %.preheader43
  %38 = load i32, ptr %34, align 4, !tbaa !9
  %39 = icmp sgt i32 %38, 0
  br i1 %39, label %.preheader, label %._crit_edge52

40:                                               ; preds = %24, %20, %16, %12, %3
  %41 = landingpad { ptr, i32 }
          cleanup
  br label %73

42:                                               ; preds = %26
  %43 = landingpad { ptr, i32 }
          cleanup
  br label %.split

44:                                               ; preds = %28
  %45 = landingpad { ptr, i32 }
          cleanup
  call void @_ZdlPvm(ptr noundef nonnull %27, i64 noundef 208) #10
  br label %.split

.preheader:                                       ; preds = %.preheader.lr.ph, %._crit_edge
  %46 = phi i32 [ %62, %._crit_edge ], [ %38, %.preheader.lr.ph ]
  %.03549 = phi i32 [ %63, %._crit_edge ], [ 0, %.preheader.lr.ph ]
  %47 = icmp sgt i32 %46, 0
  br i1 %47, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %.preheader
  switch i32 %1, label %.lr.ph.split [
    i32 0, label %.lr.ph.split.us
    i32 1, label %.lr.ph.split.us45
  ]

.lr.ph.split.us:                                  ; preds = %.lr.ph, %50
  %.03444.us = phi i32 [ %51, %50 ], [ %1, %.lr.ph ]
  %48 = invoke noundef double @_ZNK6R3Grid9GridValueEiii(ptr noundef nonnull align 8 dereferenceable(592) %0, i32 noundef %2, i32 noundef %.03549, i32 noundef %.03444.us)
          to label %49 unwind label %.split.us

49:                                               ; preds = %.lr.ph.split.us
  invoke void @_ZN6R2Grid12SetGridValueEiid(ptr noundef nonnull align 8 dereferenceable(208) %27, i32 noundef %.03549, i32 noundef %.03444.us, double noundef %48)
          to label %50 unwind label %.split.us

50:                                               ; preds = %49
  %51 = add nuw nsw i32 %.03444.us, 1
  %52 = load i32, ptr %34, align 4, !tbaa !9
  %53 = icmp slt i32 %51, %52
  br i1 %53, label %.lr.ph.split.us, label %._crit_edge, !llvm.loop !11

.split.us:                                        ; preds = %49, %.lr.ph.split.us
  %54 = landingpad { ptr, i32 }
          cleanup
  br label %.split

.lr.ph.split.us45:                                ; preds = %.lr.ph, %57
  %.03444.us46 = phi i32 [ %58, %57 ], [ 0, %.lr.ph ]
  %55 = invoke noundef double @_ZNK6R3Grid9GridValueEiii(ptr noundef nonnull align 8 dereferenceable(592) %0, i32 noundef %.03444.us46, i32 noundef %2, i32 noundef %.03549)
          to label %56 unwind label %.split.split.us

56:                                               ; preds = %.lr.ph.split.us45
  invoke void @_ZN6R2Grid12SetGridValueEiid(ptr noundef nonnull align 8 dereferenceable(208) %27, i32 noundef %.03549, i32 noundef %.03444.us46, double noundef %55)
          to label %57 unwind label %.split.split.us

57:                                               ; preds = %56
  %58 = add nuw nsw i32 %.03444.us46, 1
  %59 = load i32, ptr %34, align 4, !tbaa !9
  %60 = icmp slt i32 %58, %59
  br i1 %60, label %.lr.ph.split.us45, label %._crit_edge, !llvm.loop !11

.split.split.us:                                  ; preds = %56, %.lr.ph.split.us45
  %61 = landingpad { ptr, i32 }
          cleanup
  br label %.split

._crit_edge:                                      ; preds = %57, %50, %69, %.preheader
  %62 = phi i32 [ %46, %.preheader ], [ %71, %69 ], [ %52, %50 ], [ %59, %57 ]
  %63 = add nuw nsw i32 %.03549, 1
  %64 = load i32, ptr %31, align 4, !tbaa !9
  %65 = icmp slt i32 %63, %64
  br i1 %65, label %.preheader, label %._crit_edge52, !llvm.loop !13

.lr.ph.split:                                     ; preds = %.lr.ph, %69
  %.03444 = phi i32 [ %70, %69 ], [ 0, %.lr.ph ]
  %66 = invoke noundef double @_ZNK6R3Grid9GridValueEiii(ptr noundef nonnull align 8 dereferenceable(592) %0, i32 noundef %.03549, i32 noundef %.03444, i32 noundef %2)
          to label %68 unwind label %.split.split

.split.split:                                     ; preds = %68, %.lr.ph.split
  %67 = landingpad { ptr, i32 }
          cleanup
  br label %.split

68:                                               ; preds = %.lr.ph.split
  invoke void @_ZN6R2Grid12SetGridValueEiid(ptr noundef nonnull align 8 dereferenceable(208) %27, i32 noundef %.03549, i32 noundef %.03444, double noundef %66)
          to label %69 unwind label %.split.split

69:                                               ; preds = %68
  %70 = add nuw nsw i32 %.03444, 1
  %71 = load i32, ptr %34, align 4, !tbaa !9
  %72 = icmp slt i32 %70, %71
  br i1 %72, label %.lr.ph.split, label %._crit_edge, !llvm.loop !11

._crit_edge52:                                    ; preds = %._crit_edge, %.preheader.lr.ph, %.preheader43
  call void @_ZN7R2SolidD2Ev(ptr noundef nonnull align 8 dereferenceable(40) %5) #8
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %5) #8
  call void @_ZN7R3SolidD2Ev(ptr noundef nonnull align 8 dereferenceable(56) %4) #8
  call void @llvm.lifetime.end.p0(i64 56, ptr nonnull %4) #8
  ret ptr %27

.split:                                           ; preds = %.split.us, %.split.split.us, %.split.split, %44, %42
  %.pn = phi { ptr, i32 } [ %45, %44 ], [ %43, %42 ], [ %54, %.split.us ], [ %67, %.split.split ], [ %61, %.split.split.us ]
  call void @_ZN7R2SolidD2Ev(ptr noundef nonnull align 8 dereferenceable(40) %5) #8
  br label %73

73:                                               ; preds = %.split, %40
  %.pn.pn = phi { ptr, i32 } [ %.pn, %.split ], [ %41, %40 ]
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %5) #8
  call void @_ZN7R3SolidD2Ev(ptr noundef nonnull align 8 dereferenceable(56) %4) #8
  call void @llvm.lifetime.end.p0(i64 56, ptr nonnull %4) #8
  resume { ptr, i32 } %.pn.pn
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZNK6R3Grid8WorldBoxEv(ptr dead_on_unwind noalias writable sret(%class.R3Box) align 8, ptr noundef nonnull align 8 dereferenceable(592)) local_unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(24) ptr @_ZN5R3BoxixEi(ptr noundef nonnull align 8 dereferenceable(56), i32 noundef) local_unnamed_addr #3 align 2

declare void @_ZN5R2BoxC1Edddd(ptr noundef nonnull align 8 dereferenceable(40), double noundef, double noundef, double noundef, double noundef) unnamed_addr #4

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) local_unnamed_addr #5

declare void @_ZN6R2GridC1EiiRK5R2Box(ptr noundef nonnull align 8 dereferenceable(208), i32 noundef, i32 noundef, ptr noundef nonnull align 8 dereferenceable(40)) unnamed_addr #4

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) local_unnamed_addr #6

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN6R2Grid12SetGridValueEiid(ptr noundef nonnull align 8 dereferenceable(208), i32 noundef, i32 noundef, double noundef) local_unnamed_addr #1 align 2

; Function Attrs: nounwind
declare void @_ZN7R2SolidD2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #7

; Function Attrs: nounwind
declare void @_ZN7R3SolidD2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #7

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 = { 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 = { inlinehint 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 #4 = { "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 = { nobuiltin allocsize(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 = { nobuiltin 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 #7 = { 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 #8 = { nounwind }
attributes #9 = { builtin allocsize(0) }
attributes #10 = { builtin 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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12, !14}
!14 = !{!"llvm.loop.unswitch.partial.disable"}


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