; LLVM IR from niessner/Matterport :: code/gaps/pkgs/R2Shapes/R2Grid.ll (ZN6R2GridC2ERK5R2Boxdii)

; 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.R2Grid = type { %class.R2Affine, %class.R2Affine, double, ptr, [2 x i32], i32, i32 }
%class.R2Affine = type <{ %class.R2Transformation, %class.R3Matrix, i32, [4 x i8] }>
%class.R2Transformation = type { ptr }
%class.R3Matrix = type { [3 x [3 x double]] }

@.str = external hidden unnamed_addr constant [41 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [88 x i8], align 1
@RN_EPSILON = external global double, align 8

declare void @_ZN8R2AffineC1Ev(ptr noundef nonnull align 8 dereferenceable(84)) unnamed_addr #0

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare { i64, i1 } @llvm.umul.with.overflow.i64(i64, i64) #1

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

declare void @_Z7RNAbortPKcz(ptr noundef, ...) #0

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN6R2Grid28SetWorldToGridTransformationERK5R2Box(ptr noundef nonnull align 8 dereferenceable(208), ptr noundef nonnull align 8 dereferenceable(40)) #5 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6R2GridC2ERK5R2Boxdii(ptr noundef nonnull align 8 dereferenceable(208) %0, ptr noundef nonnull align 8 dereferenceable(40) %1, double noundef %2, i32 noundef %3, i32 noundef %4) unnamed_addr #5 align 2 personality ptr @__gxx_personality_v0 {
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca double, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca %class.R2Grid, align 8
  %14 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store double %2, ptr %8, align 8, !tbaa !9
  store i32 %3, ptr %9, align 4, !tbaa !11
  store i32 %4, ptr %10, align 4, !tbaa !11
  %15 = load ptr, ptr %6, align 8
  %16 = getelementptr inbounds %class.R2Grid, ptr %15, i32 0, i32 0
  call void @_ZN8R2AffineC1Ev(ptr noundef nonnull align 8 dereferenceable(84) %16)
  %17 = getelementptr inbounds %class.R2Grid, ptr %15, i32 0, i32 1
  invoke void @_ZN8R2AffineC1Ev(ptr noundef nonnull align 8 dereferenceable(84) %17)
          to label %18 unwind label %33

18:                                               ; preds = %5
  %19 = load ptr, ptr %7, align 8, !tbaa !5
  %20 = invoke noundef i32 @_ZNK5R2Box7IsEmptyEv(ptr noundef nonnull align 8 dereferenceable(40) %19)
          to label %21 unwind label %37

21:                                               ; preds = %18
  %22 = icmp ne i32 %20, 0
  br i1 %22, label %29, label %23

23:                                               ; preds = %21
  %24 = load double, ptr %8, align 8, !tbaa !9
  %25 = load double, ptr @RN_EPSILON, align 8, !tbaa !9
  %26 = invoke noundef i32 @_Z8RNIsZerodd(double noundef %24, double noundef %25)
          to label %27 unwind label %37

27:                                               ; preds = %23
  %28 = icmp ne i32 %26, 0
  br i1 %28, label %29, label %50

29:                                               ; preds = %27, %21
  call void @llvm.lifetime.start.p0(i64 208, ptr %13) #7
  invoke void @_ZN6R2GridC1Eii(ptr noundef nonnull align 8 dereferenceable(208) %13, i32 noundef 0, i32 noundef 0)
          to label %30 unwind label %41

30:                                               ; preds = %29
  %31 = invoke noundef nonnull align 8 dereferenceable(208) ptr @_ZN6R2GridaSERKS_(ptr noundef nonnull align 8 dereferenceable(208) %15, ptr noundef nonnull align 8 dereferenceable(208) %13)
          to label %32 unwind label %45

32:                                               ; preds = %30
  call void @_ZN6R2GridD1Ev(ptr noundef nonnull align 8 dereferenceable(208) %13) #7
  call void @llvm.lifetime.end.p0(i64 208, ptr %13) #7
  br label %184

33:                                               ; preds = %5
  %34 = landingpad { ptr, i32 }
          cleanup
  %35 = extractvalue { ptr, i32 } %34, 0
  store ptr %35, ptr %11, align 8
  %36 = extractvalue { ptr, i32 } %34, 1
  store i32 %36, ptr %12, align 4
  br label %186

37:                                               ; preds = %182, %164, %145, %89, %86, %78, %69, %62, %53, %23, %18
  %38 = landingpad { ptr, i32 }
          cleanup
  %39 = extractvalue { ptr, i32 } %38, 0
  store ptr %39, ptr %11, align 8
  %40 = extractvalue { ptr, i32 } %38, 1
  store i32 %40, ptr %12, align 4
  br label %185

41:                                               ; preds = %29
  %42 = landingpad { ptr, i32 }
          cleanup
  %43 = extractvalue { ptr, i32 } %42, 0
  store ptr %43, ptr %11, align 8
  %44 = extractvalue { ptr, i32 } %42, 1
  store i32 %44, ptr %12, align 4
  br label %49

45:                                               ; preds = %30
  %46 = landingpad { ptr, i32 }
          cleanup
  %47 = extractvalue { ptr, i32 } %46, 0
  store ptr %47, ptr %11, align 8
  %48 = extractvalue { ptr, i32 } %46, 1
  store i32 %48, ptr %12, align 4
  call void @_ZN6R2GridD1Ev(ptr noundef nonnull align 8 dereferenceable(208) %13) #7
  br label %49

49:                                               ; preds = %45, %41
  call void @llvm.lifetime.end.p0(i64 208, ptr %13) #7
  br label %185

50:                                               ; preds = %27
  %51 = load i32, ptr %10, align 4, !tbaa !11
  %52 = icmp sgt i32 %51, 0
  br i1 %52, label %53, label %86

53:                                               ; preds = %50
  %54 = load ptr, ptr %7, align 8, !tbaa !5
  %55 = invoke noundef double @_ZNK5R2Box7XLengthEv(ptr noundef nonnull align 8 dereferenceable(40) %54)
          to label %56 unwind label %37

56:                                               ; preds = %53
  %57 = load double, ptr %8, align 8, !tbaa !9
  %58 = fdiv double %55, %57
  %59 = load i32, ptr %10, align 4, !tbaa !11
  %60 = sitofp i32 %59 to double
  %61 = fcmp ogt double %58, %60
  br i1 %61, label %62, label %69

62:                                               ; preds = %56
  %63 = load ptr, ptr %7, align 8, !tbaa !5
  %64 = invoke noundef double @_ZNK5R2Box7XLengthEv(ptr noundef nonnull align 8 dereferenceable(40) %63)
          to label %65 unwind label %37

65:                                               ; preds = %62
  %66 = load i32, ptr %10, align 4, !tbaa !11
  %67 = sitofp i32 %66 to double
  %68 = fdiv double %64, %67
  store double %68, ptr %8, align 8, !tbaa !9
  br label %69

69:                                               ; preds = %65, %56
  %70 = load ptr, ptr %7, align 8, !tbaa !5
  %71 = invoke noundef double @_ZNK5R2Box7YLengthEv(ptr noundef nonnull align 8 dereferenceable(40) %70)
          to label %72 unwind label %37

72:                                               ; preds = %69
  %73 = load double, ptr %8, align 8, !tbaa !9
  %74 = fdiv double %71, %73
  %75 = load i32, ptr %10, align 4, !tbaa !11
  %76 = sitofp i32 %75 to double
  %77 = fcmp ogt double %74, %76
  br i1 %77, label %78, label %85

78:                                               ; preds = %72
  %79 = load ptr, ptr %7, align 8, !tbaa !5
  %80 = invoke noundef double @_ZNK5R2Box7YLengthEv(ptr noundef nonnull align 8 dereferenceable(40) %79)
          to label %81 unwind label %37

81:                                               ; preds = %78
  %82 = load i32, ptr %10, align 4, !tbaa !11
  %83 = sitofp i32 %82 to double
  %84 = fdiv double %80, %83
  store double %84, ptr %8, align 8, !tbaa !9
  br label %85

85:                                               ; preds = %81, %72
  br label %86

86:                                               ; preds = %85, %50
  %87 = load ptr, ptr %7, align 8, !tbaa !5
  %88 = invoke noundef double @_ZNK5R2Box7XLengthEv(ptr noundef nonnull align 8 dereferenceable(40) %87)
          to label %89 unwind label %37

89:                                               ; preds = %86
  %90 = load double, ptr %8, align 8, !tbaa !9
  %91 = fdiv double %88, %90
  %92 = fadd double %91, 5.000000e-01
  %93 = fptosi double %92 to i32
  %94 = getelementptr inbounds %class.R2Grid, ptr %15, i32 0, i32 4
  %95 = getelementptr inbounds [2 x i32], ptr %94, i64 0, i64 0
  store i32 %93, ptr %95, align 8, !tbaa !11
  %96 = load ptr, ptr %7, align 8, !tbaa !5
  %97 = invoke noundef double @_ZNK5R2Box7YLengthEv(ptr noundef nonnull align 8 dereferenceable(40) %96)
          to label %98 unwind label %37

98:                                               ; preds = %89
  %99 = load double, ptr %8, align 8, !tbaa !9
  %100 = fdiv double %97, %99
  %101 = fadd double %100, 5.000000e-01
  %102 = fptosi double %101 to i32
  %103 = getelementptr inbounds %class.R2Grid, ptr %15, i32 0, i32 4
  %104 = getelementptr inbounds [2 x i32], ptr %103, i64 0, i64 1
  store i32 %102, ptr %104, align 4, !tbaa !11
  %105 = load i32, ptr %9, align 4, !tbaa !11
  %106 = icmp sgt i32 %105, 0
  br i1 %106, label %107, label %128

107:                                              ; preds = %98
  %108 = getelementptr inbounds %class.R2Grid, ptr %15, i32 0, i32 4
  %109 = getelementptr inbounds [2 x i32], ptr %108, i64 0, i64 0
  %110 = load i32, ptr %109, align 8, !tbaa !11
  %111 = load i32, ptr %9, align 4, !tbaa !11
  %112 = icmp slt i32 %110, %111
  br i1 %112, label %113, label %117

113:                                              ; preds = %107
  %114 = load i32, ptr %9, align 4, !tbaa !11
  %115 = getelementptr inbounds %class.R2Grid, ptr %15, i32 0, i32 4
  %116 = getelementptr inbounds [2 x i32], ptr %115, i64 0, i64 0
  store i32 %114, ptr %116, align 8, !tbaa !11
  br label %117

117:                                              ; preds = %113, %107
  %118 = getelementptr inbounds %class.R2Grid, ptr %15, i32 0, i32 4
  %119 = getelementptr inbounds [2 x i32], ptr %118, i64 0, i64 1
  %120 = load i32, ptr %119, align 4, !tbaa !11
  %121 = load i32, ptr %9, align 4, !tbaa !11
  %122 = icmp slt i32 %120, %121
  br i1 %122, label %123, label %127

123:                                              ; preds = %117
  %124 = load i32, ptr %9, align 4, !tbaa !11
  %125 = getelementptr inbounds %class.R2Grid, ptr %15, i32 0, i32 4
  %126 = getelementptr inbounds [2 x i32], ptr %125, i64 0, i64 1
  store i32 %124, ptr %126, align 4, !tbaa !11
  br label %127

127:                                              ; preds = %123, %117
  br label %128

128:                                              ; preds = %127, %98
  %129 = getelementptr inbounds %class.R2Grid, ptr %15, i32 0, i32 4
  %130 = getelementptr inbounds [2 x i32], ptr %129, i64 0, i64 0
  %131 = load i32, ptr %130, align 8, !tbaa !11
  %132 = getelementptr inbounds %class.R2Grid, ptr %15, i32 0, i32 5
  store i32 %131, ptr %132, align 8, !tbaa !13
  %133 = getelementptr inbounds %class.R2Grid, ptr %15, i32 0, i32 5
  %134 = load i32, ptr %133, align 8, !tbaa !13
  %135 = getelementptr inbounds %class.R2Grid, ptr %15, i32 0, i32 4
  %136 = getelementptr inbounds [2 x i32], ptr %135, i64 0, i64 1
  %137 = load i32, ptr %136, align 4, !tbaa !11
  %138 = mul nsw i32 %134, %137
  %139 = getelementptr inbounds %class.R2Grid, ptr %15, i32 0, i32 6
  store i32 %138, ptr %139, align 4, !tbaa !18
  %140 = getelementptr inbounds %class.R2Grid, ptr %15, i32 0, i32 6
  %141 = load i32, ptr %140, align 4, !tbaa !18
  %142 = icmp eq i32 %141, 0
  br i1 %142, label %143, label %145

143:                                              ; preds = %128
  %144 = getelementptr inbounds %class.R2Grid, ptr %15, i32 0, i32 3
  store ptr null, ptr %144, align 8, !tbaa !19
  br label %156

145:                                              ; preds = %128
  %146 = getelementptr inbounds %class.R2Grid, ptr %15, i32 0, i32 6
  %147 = load i32, ptr %146, align 4, !tbaa !18
  %148 = sext i32 %147 to i64
  %149 = call { i64, i1 } @llvm.umul.with.overflow.i64(i64 %148, i64 8)
  %150 = extractvalue { i64, i1 } %149, 1
  %151 = extractvalue { i64, i1 } %149, 0
  %152 = select i1 %150, i64 -1, i64 %151
  %153 = invoke noalias noundef nonnull ptr @_Znam(i64 noundef %152) #8
          to label %154 unwind label %37

154:                                              ; preds = %145
  %155 = getelementptr inbounds %class.R2Grid, ptr %15, i32 0, i32 3
  store ptr %153, ptr %155, align 8, !tbaa !19
  br label %156

156:                                              ; preds = %154, %143
  %157 = getelementptr inbounds %class.R2Grid, ptr %15, i32 0, i32 6
  %158 = load i32, ptr %157, align 4, !tbaa !18
  %159 = icmp ne i32 %158, 0
  br i1 %159, label %160, label %166

160:                                              ; preds = %156
  %161 = getelementptr inbounds %class.R2Grid, ptr %15, i32 0, i32 3
  %162 = load ptr, ptr %161, align 8, !tbaa !19
  %163 = icmp ne ptr %162, null
  br i1 %163, label %166, label %164

164:                                              ; preds = %160
  invoke void (ptr, ...) @_Z7RNAbortPKcz(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 160, ptr noundef @.str.2)
          to label %165 unwind label %37

165:                                              ; preds = %164
  br label %166

166:                                              ; preds = %165, %160, %156
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #7
  store i32 0, ptr %14, align 4, !tbaa !11
  br label %167

167:                                              ; preds = %179, %166
  %168 = load i32, ptr %14, align 4, !tbaa !11
  %169 = getelementptr inbounds %class.R2Grid, ptr %15, i32 0, i32 6
  %170 = load i32, ptr %169, align 4, !tbaa !18
  %171 = icmp slt i32 %168, %170
  br i1 %171, label %173, label %172

172:                                              ; preds = %167
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #7
  br label %182

173:                                              ; preds = %167
  %174 = getelementptr inbounds %class.R2Grid, ptr %15, i32 0, i32 3
  %175 = load ptr, ptr %174, align 8, !tbaa !19
  %176 = load i32, ptr %14, align 4, !tbaa !11
  %177 = sext i32 %176 to i64
  %178 = getelementptr inbounds double, ptr %175, i64 %177
  store double 0.000000e+00, ptr %178, align 8, !tbaa !9
  br label %179

179:                                              ; preds = %173
  %180 = load i32, ptr %14, align 4, !tbaa !11
  %181 = add nsw i32 %180, 1
  store i32 %181, ptr %14, align 4, !tbaa !11
  br label %167, !llvm.loop !20

182:                                              ; preds = %172
  %183 = load ptr, ptr %7, align 8, !tbaa !5
  invoke void @_ZN6R2Grid28SetWorldToGridTransformationERK5R2Box(ptr noundef nonnull align 8 dereferenceable(208) %15, ptr noundef nonnull align 8 dereferenceable(40) %183)
          to label %184 unwind label %37

184:                                              ; preds = %182, %32
  ret void

185:                                              ; preds = %49, %37
  call void @_ZN16R2TransformationD2Ev(ptr noundef nonnull align 8 dereferenceable(84) %17) #7
  br label %186

186:                                              ; preds = %185, %33
  call void @_ZN16R2TransformationD2Ev(ptr noundef nonnull align 8 dereferenceable(84) %16) #7
  br label %187

187:                                              ; preds = %186
  %188 = load ptr, ptr %11, align 8
  %189 = load i32, ptr %12, align 4
  %190 = insertvalue { ptr, i32 } poison, ptr %188, 0
  %191 = insertvalue { ptr, i32 } %190, i32 %189, 1
  resume { ptr, i32 } %191
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_ZNK5R2Box7IsEmptyEv(ptr noundef nonnull align 8 dereferenceable(40)) #6 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_Z8RNIsZerodd(double noundef, double noundef) #6

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(208) ptr @_ZN6R2GridaSERKS_(ptr noundef nonnull align 8 dereferenceable(208), ptr noundef nonnull align 8 dereferenceable(208)) #5 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef double @_ZNK5R2Box7XLengthEv(ptr noundef nonnull align 8 dereferenceable(40)) #6 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef double @_ZNK5R2Box7YLengthEv(ptr noundef nonnull align 8 dereferenceable(40)) #6 align 2

declare void @_ZN6R2GridC1Eii(ptr, i32, i32)

declare void @_ZN6R2GridD1Ev(ptr)

attributes #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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { 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 #3 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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 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 = { 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 #7 = { nounwind }
attributes #8 = { builtin allocsize(0) }

!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 = !{!"double", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !12, i64 200}
!14 = !{!"_ZTS6R2Grid", !15, i64 0, !15, i64 88, !10, i64 176, !6, i64 184, !7, i64 192, !12, i64 200, !12, i64 204}
!15 = !{!"_ZTS8R2Affine", !16, i64 0, !17, i64 8, !12, i64 80}
!16 = !{!"_ZTS16R2Transformation"}
!17 = !{!"_ZTS8R3Matrix", !7, i64 0}
!18 = !{!14, !12, i64 204}
!19 = !{!14, !6, i64 184}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%class.R2Grid = type { %class.R2Affine, %class.R2Affine, double, ptr, [2 x i32], i32, i32 }
%class.R2Affine = type <{ %class.R2Transformation, %class.R3Matrix, i32, [4 x i8] }>
%class.R2Transformation = type { ptr }
%class.R3Matrix = type { [3 x [3 x double]] }

@RN_EPSILON = external local_unnamed_addr global double, align 8

declare void @_ZN8R2AffineC1Ev(ptr noundef nonnull align 8 dereferenceable(84)) unnamed_addr #0

declare i32 @__gxx_personality_v0(...)

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

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN6R2Grid28SetWorldToGridTransformationERK5R2Box(ptr noundef nonnull align 8 dereferenceable(208), ptr noundef nonnull align 8 dereferenceable(40)) local_unnamed_addr #4 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6R2GridC2ERK5R2Boxdii(ptr noundef nonnull align 8 dereferenceable(208) %0, ptr noundef nonnull align 8 dereferenceable(40) %1, double noundef %2, i32 noundef %3, i32 noundef %4) unnamed_addr #4 align 2 personality ptr @__gxx_personality_v0 {
  %6 = alloca %class.R2Grid, align 8
  tail call void @_ZN8R2AffineC1Ev(ptr noundef nonnull align 8 dereferenceable(84) %0)
  %7 = getelementptr inbounds i8, ptr %0, i64 88
  invoke void @_ZN8R2AffineC1Ev(ptr noundef nonnull align 8 dereferenceable(84) %7)
          to label %8 unwind label %19

8:                                                ; preds = %5
  %9 = invoke noundef i32 @_ZNK5R2Box7IsEmptyEv(ptr noundef nonnull align 8 dereferenceable(40) %1)
          to label %10 unwind label %21

10:                                               ; preds = %8
  %.not = icmp eq i32 %9, 0
  br i1 %.not, label %11, label %15

11:                                               ; preds = %10
  %12 = load double, ptr @RN_EPSILON, align 8, !tbaa !5
  %13 = invoke noundef i32 @_Z8RNIsZerodd(double noundef %2, double noundef %12)
          to label %14 unwind label %21

14:                                               ; preds = %11
  %.not39 = icmp eq i32 %13, 0
  br i1 %.not39, label %28, label %15

15:                                               ; preds = %14, %10
  call void @llvm.lifetime.start.p0(i64 208, ptr nonnull %6) #7
  invoke void @_ZN6R2GridC1Eii(ptr noundef nonnull align 8 dereferenceable(208) %6, i32 noundef 0, i32 noundef 0)
          to label %16 unwind label %23

16:                                               ; preds = %15
  %17 = invoke noundef nonnull align 8 dereferenceable(208) ptr @_ZN6R2GridaSERKS_(ptr noundef nonnull align 8 dereferenceable(208) %0, ptr noundef nonnull align 8 dereferenceable(208) %6)
          to label %18 unwind label %25

18:                                               ; preds = %16
  call void @_ZN6R2GridD1Ev(ptr noundef nonnull align 8 dereferenceable(208) %6) #7
  call void @llvm.lifetime.end.p0(i64 208, ptr nonnull %6) #7
  br label %89

19:                                               ; preds = %5
  %20 = landingpad { ptr, i32 }
          cleanup
  br label %91

21:                                               ; preds = %._crit_edge, %78, %51, %49, %45, %40, %36, %30, %11, %8
  %22 = landingpad { ptr, i32 }
          cleanup
  br label %90

23:                                               ; preds = %15
  %24 = landingpad { ptr, i32 }
          cleanup
  br label %27

25:                                               ; preds = %16
  %26 = landingpad { ptr, i32 }
          cleanup
  call void @_ZN6R2GridD1Ev(ptr noundef nonnull align 8 dereferenceable(208) %6) #7
  br label %27

27:                                               ; preds = %25, %23
  %.pn = phi { ptr, i32 } [ %26, %25 ], [ %24, %23 ]
  call void @llvm.lifetime.end.p0(i64 208, ptr nonnull %6) #7
  br label %90

28:                                               ; preds = %14
  %29 = icmp sgt i32 %4, 0
  br i1 %29, label %30, label %49

30:                                               ; preds = %28
  %31 = invoke noundef double @_ZNK5R2Box7XLengthEv(ptr noundef nonnull align 8 dereferenceable(40) %1)
          to label %32 unwind label %21

32:                                               ; preds = %30
  %33 = fdiv double %31, %2
  %34 = uitofp nneg i32 %4 to double
  %35 = fcmp ogt double %33, %34
  br i1 %35, label %36, label %40

36:                                               ; preds = %32
  %37 = invoke noundef double @_ZNK5R2Box7XLengthEv(ptr noundef nonnull align 8 dereferenceable(40) %1)
          to label %38 unwind label %21

38:                                               ; preds = %36
  %39 = fdiv double %37, %34
  br label %40

40:                                               ; preds = %38, %32
  %.032 = phi double [ %39, %38 ], [ %2, %32 ]
  %41 = invoke noundef double @_ZNK5R2Box7YLengthEv(ptr noundef nonnull align 8 dereferenceable(40) %1)
          to label %42 unwind label %21

42:                                               ; preds = %40
  %43 = fdiv double %41, %.032
  %44 = fcmp ogt double %43, %34
  br i1 %44, label %45, label %49

45:                                               ; preds = %42
  %46 = invoke noundef double @_ZNK5R2Box7YLengthEv(ptr noundef nonnull align 8 dereferenceable(40) %1)
          to label %47 unwind label %21

47:                                               ; preds = %45
  %48 = fdiv double %46, %34
  br label %49

49:                                               ; preds = %42, %47, %28
  %.133 = phi double [ %48, %47 ], [ %.032, %42 ], [ %2, %28 ]
  %50 = invoke noundef double @_ZNK5R2Box7XLengthEv(ptr noundef nonnull align 8 dereferenceable(40) %1)
          to label %51 unwind label %21

51:                                               ; preds = %49
  %52 = fdiv double %50, %.133
  %53 = fadd double %52, 5.000000e-01
  %54 = fptosi double %53 to i32
  %55 = getelementptr inbounds i8, ptr %0, i64 192
  store i32 %54, ptr %55, align 8, !tbaa !9
  %56 = invoke noundef double @_ZNK5R2Box7YLengthEv(ptr noundef nonnull align 8 dereferenceable(40) %1)
          to label %57 unwind label %21

57:                                               ; preds = %51
  %58 = fdiv double %56, %.133
  %59 = fadd double %58, 5.000000e-01
  %60 = fptosi double %59 to i32
  %61 = getelementptr inbounds i8, ptr %0, i64 196
  store i32 %60, ptr %61, align 4, !tbaa !9
  %62 = icmp sgt i32 %3, 0
  %.pre = load i32, ptr %55, align 8, !tbaa !9
  br i1 %62, label %63, label %70

63:                                               ; preds = %57
  %64 = icmp slt i32 %.pre, %3
  br i1 %64, label %65, label %66

65:                                               ; preds = %63
  store i32 %3, ptr %55, align 8, !tbaa !9
  br label %66

66:                                               ; preds = %65, %63
  %67 = phi i32 [ %3, %65 ], [ %.pre, %63 ]
  %68 = icmp slt i32 %60, %3
  br i1 %68, label %69, label %70

69:                                               ; preds = %66
  store i32 %3, ptr %61, align 4, !tbaa !9
  br label %70

70:                                               ; preds = %66, %69, %57
  %71 = phi i32 [ %60, %66 ], [ %3, %69 ], [ %60, %57 ]
  %72 = phi i32 [ %67, %66 ], [ %67, %69 ], [ %.pre, %57 ]
  %73 = getelementptr inbounds i8, ptr %0, i64 200
  store i32 %72, ptr %73, align 8, !tbaa !11
  %74 = mul nsw i32 %71, %72
  %75 = getelementptr inbounds i8, ptr %0, i64 204
  store i32 %74, ptr %75, align 4, !tbaa !17
  %76 = icmp eq i32 %74, 0
  br i1 %76, label %.thread51, label %78

.thread51:                                        ; preds = %70
  %77 = getelementptr inbounds i8, ptr %0, i64 184
  store ptr null, ptr %77, align 8, !tbaa !18
  br label %._crit_edge

78:                                               ; preds = %70
  %79 = sext i32 %74 to i64
  %80 = icmp slt i32 %74, 0
  %81 = shl nsw i64 %79, 3
  %82 = select i1 %80, i64 -1, i64 %81
  %83 = invoke noalias noundef nonnull ptr @_Znam(i64 noundef %82) #8
          to label %84 unwind label %21

84:                                               ; preds = %78
  %85 = getelementptr inbounds i8, ptr %0, i64 184
  store ptr %83, ptr %85, align 8, !tbaa !18
  %86 = icmp sgt i32 %74, 0
  br i1 %86, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %84
  %87 = zext nneg i32 %74 to i64
  %88 = shl nuw nsw i64 %87, 3
  tail call void @llvm.memset.p0.i64(ptr nonnull align 8 %83, i8 0, i64 %88, i1 false), !tbaa !5
  br label %._crit_edge

._crit_edge:                                      ; preds = %.thread51, %.lr.ph, %84
  invoke void @_ZN6R2Grid28SetWorldToGridTransformationERK5R2Box(ptr noundef nonnull align 8 dereferenceable(208) %0, ptr noundef nonnull align 8 dereferenceable(40) %1)
          to label %89 unwind label %21

89:                                               ; preds = %._crit_edge, %18
  ret void

90:                                               ; preds = %27, %21
  %.pn.pn = phi { ptr, i32 } [ %.pn, %27 ], [ %22, %21 ]
  call void @_ZN16R2TransformationD2Ev(ptr noundef nonnull align 8 dereferenceable(84) %7) #7
  br label %91

91:                                               ; preds = %90, %19
  %.pn.pn.pn = phi { ptr, i32 } [ %.pn.pn, %90 ], [ %20, %19 ]
  call void @_ZN16R2TransformationD2Ev(ptr noundef nonnull align 8 dereferenceable(84) %0) #7
  resume { ptr, i32 } %.pn.pn.pn
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_ZNK5R2Box7IsEmptyEv(ptr noundef nonnull align 8 dereferenceable(40)) local_unnamed_addr #5 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_Z8RNIsZerodd(double noundef, double noundef) local_unnamed_addr #5

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef double @_ZNK5R2Box7XLengthEv(ptr noundef nonnull align 8 dereferenceable(40)) local_unnamed_addr #5 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef double @_ZNK5R2Box7YLengthEv(ptr noundef nonnull align 8 dereferenceable(40)) local_unnamed_addr #5 align 2

declare void @_ZN6R2GridC1Eii(ptr, i32, i32) local_unnamed_addr

declare void @_ZN6R2GridD1Ev(ptr) local_unnamed_addr

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #6

attributes #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 = { 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 #2 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #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 = { 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 #6 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #7 = { nounwind }
attributes #8 = { builtin allocsize(0) }

!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 = !{!12, !10, i64 200}
!12 = !{!"_ZTS6R2Grid", !13, i64 0, !13, i64 88, !6, i64 176, !16, i64 184, !7, i64 192, !10, i64 200, !10, i64 204}
!13 = !{!"_ZTS8R2Affine", !14, i64 0, !15, i64 8, !10, i64 80}
!14 = !{!"_ZTS16R2Transformation"}
!15 = !{!"_ZTS8R3Matrix", !7, i64 0}
!16 = !{!"any pointer", !7, i64 0}
!17 = !{!12, !10, i64 204}
!18 = !{!12, !16, i64 184}


; Effective O3 passes: BDCEPass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopIdiomRecognizePass,LoopRotatePass,LoopSimplifyPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass