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

; 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.R2Box = type { %class.R2Solid, %class.R2Point, %class.R2Point }
%class.R2Solid = type { %class.R2Shape }
%class.R2Shape = type { ptr }
%class.R2Point = type { [2 x double] }
%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.2 = external hidden unnamed_addr constant [88 x i8], align 1
@.str.23 = external hidden unnamed_addr constant [16 x i8], align 1

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) #0

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

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

; 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: mustprogress uwtable
declare dso_local void @_ZN6R2Grid28SetWorldToGridTransformationERK5R2Box(ptr noundef nonnull align 8 dereferenceable(208), ptr noundef nonnull align 8 dereferenceable(40)) #4 align 2

; Function Attrs: nobuiltin nounwind
declare void @_ZdaPv(ptr noundef) #5

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6R2Grid8ResampleEii(ptr noundef nonnull align 8 dereferenceable(208) %0, i32 noundef %1, i32 noundef %2) #4 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca double, align 8
  %11 = alloca double, align 8
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca double, align 8
  %15 = alloca i32, align 4
  %16 = alloca double, align 8
  %17 = alloca i32, align 4
  %18 = alloca %class.R2Box, align 8
  %19 = alloca ptr, align 8
  %20 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  store i32 %2, ptr %6, align 4, !tbaa !9
  %21 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #8
  store ptr null, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #8
  %22 = load i32, ptr %5, align 4, !tbaa !9
  %23 = load i32, ptr %6, align 4, !tbaa !9
  %24 = mul nsw i32 %22, %23
  store i32 %24, ptr %8, align 4, !tbaa !9
  %25 = load i32, ptr %8, align 4, !tbaa !9
  %26 = icmp sgt i32 %25, 0
  br i1 %26, label %27, label %147

27:                                               ; preds = %3
  %28 = load i32, ptr %8, align 4, !tbaa !9
  %29 = sext i32 %28 to i64
  %30 = call { i64, i1 } @llvm.umul.with.overflow.i64(i64 %29, i64 8)
  %31 = extractvalue { i64, i1 } %30, 1
  %32 = extractvalue { i64, i1 } %30, 0
  %33 = select i1 %31, i64 -1, i64 %32
  %34 = call noalias noundef nonnull ptr @_Znam(i64 noundef %33) #9
  store ptr %34, ptr %7, align 8, !tbaa !5
  %35 = load ptr, ptr %7, align 8, !tbaa !5
  %36 = icmp ne ptr %35, null
  br i1 %36, label %38, label %37

37:                                               ; preds = %27
  call void (ptr, ...) @_Z7RNAbortPKcz(ptr noundef @.str, ptr noundef @.str.23, i32 noundef 2101, ptr noundef @.str.2)
  br label %38

38:                                               ; preds = %37, %27
  %39 = getelementptr inbounds %class.R2Grid, ptr %21, i32 0, i32 3
  %40 = load ptr, ptr %39, align 8, !tbaa !11
  %41 = icmp ne ptr %40, null
  br i1 %41, label %42, label %131

42:                                               ; preds = %38
  %43 = getelementptr inbounds %class.R2Grid, ptr %21, i32 0, i32 4
  %44 = getelementptr inbounds [2 x i32], ptr %43, i64 0, i64 0
  %45 = load i32, ptr %44, align 8, !tbaa !9
  %46 = icmp sgt i32 %45, 0
  br i1 %46, label %47, label %131

47:                                               ; preds = %42
  %48 = getelementptr inbounds %class.R2Grid, ptr %21, i32 0, i32 4
  %49 = getelementptr inbounds [2 x i32], ptr %48, i64 0, i64 1
  %50 = load i32, ptr %49, align 4, !tbaa !9
  %51 = icmp sgt i32 %50, 0
  br i1 %51, label %52, label %131

52:                                               ; preds = %47
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #8
  %53 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %53, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #8
  %54 = getelementptr inbounds %class.R2Grid, ptr %21, i32 0, i32 4
  %55 = getelementptr inbounds [2 x i32], ptr %54, i64 0, i64 0
  %56 = load i32, ptr %55, align 8, !tbaa !9
  %57 = sub nsw i32 %56, 1
  %58 = sitofp i32 %57 to double
  %59 = load i32, ptr %5, align 4, !tbaa !9
  %60 = sub nsw i32 %59, 1
  %61 = sitofp i32 %60 to double
  %62 = fdiv double %58, %61
  store double %62, ptr %10, align 8, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #8
  %63 = getelementptr inbounds %class.R2Grid, ptr %21, i32 0, i32 4
  %64 = getelementptr inbounds [2 x i32], ptr %63, i64 0, i64 1
  %65 = load i32, ptr %64, align 4, !tbaa !9
  %66 = sub nsw i32 %65, 1
  %67 = sitofp i32 %66 to double
  %68 = load i32, ptr %6, align 4, !tbaa !9
  %69 = sub nsw i32 %68, 1
  %70 = sitofp i32 %69 to double
  %71 = fdiv double %67, %70
  store double %71, ptr %11, align 8, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #8
  store i32 0, ptr %12, align 4, !tbaa !9
  br label %72

72:                                               ; preds = %127, %52
  %73 = load i32, ptr %12, align 4, !tbaa !9
  %74 = load i32, ptr %6, align 4, !tbaa !9
  %75 = icmp slt i32 %73, %74
  br i1 %75, label %77, label %76

76:                                               ; preds = %72
  store i32 2, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #8
  br label %130

77:                                               ; preds = %72
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #8
  %78 = load i32, ptr %12, align 4, !tbaa !9
  %79 = load i32, ptr %6, align 4, !tbaa !9
  %80 = sub nsw i32 %79, 1
  %81 = icmp eq i32 %78, %80
  br i1 %81, label %82, label %88

82:                                               ; preds = %77
  %83 = getelementptr inbounds %class.R2Grid, ptr %21, i32 0, i32 4
  %84 = getelementptr inbounds [2 x i32], ptr %83, i64 0, i64 1
  %85 = load i32, ptr %84, align 4, !tbaa !9
  %86 = sub nsw i32 %85, 1
  %87 = sitofp i32 %86 to double
  br label %93

88:                                               ; preds = %77
  %89 = load i32, ptr %12, align 4, !tbaa !9
  %90 = sitofp i32 %89 to double
  %91 = load double, ptr %11, align 8, !tbaa !17
  %92 = fmul double %90, %91
  br label %93

93:                                               ; preds = %88, %82
  %94 = phi double [ %87, %82 ], [ %92, %88 ]
  store double %94, ptr %14, align 8, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #8
  store i32 0, ptr %15, align 4, !tbaa !9
  br label %95

95:                                               ; preds = %123, %93
  %96 = load i32, ptr %15, align 4, !tbaa !9
  %97 = load i32, ptr %5, align 4, !tbaa !9
  %98 = icmp slt i32 %96, %97
  br i1 %98, label %100, label %99

99:                                               ; preds = %95
  store i32 5, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #8
  br label %126

100:                                              ; preds = %95
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #8
  %101 = load i32, ptr %15, align 4, !tbaa !9
  %102 = load i32, ptr %5, align 4, !tbaa !9
  %103 = sub nsw i32 %102, 1
  %104 = icmp eq i32 %101, %103
  br i1 %104, label %105, label %111

105:                                              ; preds = %100
  %106 = getelementptr inbounds %class.R2Grid, ptr %21, i32 0, i32 4
  %107 = getelementptr inbounds [2 x i32], ptr %106, i64 0, i64 0
  %108 = load i32, ptr %107, align 8, !tbaa !9
  %109 = sub nsw i32 %108, 1
  %110 = sitofp i32 %109 to double
  br label %116

111:                                              ; preds = %100
  %112 = load i32, ptr %15, align 4, !tbaa !9
  %113 = sitofp i32 %112 to double
  %114 = load double, ptr %10, align 8, !tbaa !17
  %115 = fmul double %113, %114
  br label %116

116:                                              ; preds = %111, %105
  %117 = phi double [ %110, %105 ], [ %115, %111 ]
  store double %117, ptr %16, align 8, !tbaa !17
  %118 = load double, ptr %16, align 8, !tbaa !17
  %119 = load double, ptr %14, align 8, !tbaa !17
  %120 = call noundef double @_ZNK6R2Grid9GridValueEdd(ptr noundef nonnull align 8 dereferenceable(208) %21, double noundef %118, double noundef %119)
  %121 = load ptr, ptr %9, align 8, !tbaa !5
  %122 = getelementptr inbounds double, ptr %121, i32 1
  store ptr %122, ptr %9, align 8, !tbaa !5
  store double %120, ptr %121, align 8, !tbaa !17
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #8
  br label %123

123:                                              ; preds = %116
  %124 = load i32, ptr %15, align 4, !tbaa !9
  %125 = add nsw i32 %124, 1
  store i32 %125, ptr %15, align 4, !tbaa !9
  br label %95, !llvm.loop !18

126:                                              ; preds = %99
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #8
  br label %127

127:                                              ; preds = %126
  %128 = load i32, ptr %12, align 4, !tbaa !9
  %129 = add nsw i32 %128, 1
  store i32 %129, ptr %12, align 4, !tbaa !9
  br label %72, !llvm.loop !20

130:                                              ; preds = %76
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #8
  br label %146

131:                                              ; preds = %47, %42, %38
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #8
  store i32 0, ptr %17, align 4, !tbaa !9
  br label %132

132:                                              ; preds = %142, %131
  %133 = load i32, ptr %17, align 4, !tbaa !9
  %134 = load i32, ptr %8, align 4, !tbaa !9
  %135 = icmp slt i32 %133, %134
  br i1 %135, label %137, label %136

136:                                              ; preds = %132
  store i32 8, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #8
  br label %145

137:                                              ; preds = %132
  %138 = load ptr, ptr %7, align 8, !tbaa !5
  %139 = load i32, ptr %17, align 4, !tbaa !9
  %140 = sext i32 %139 to i64
  %141 = getelementptr inbounds double, ptr %138, i64 %140
  store double 0.000000e+00, ptr %141, align 8, !tbaa !17
  br label %142

142:                                              ; preds = %137
  %143 = load i32, ptr %17, align 4, !tbaa !9
  %144 = add nsw i32 %143, 1
  store i32 %144, ptr %17, align 4, !tbaa !9
  br label %132, !llvm.loop !21

145:                                              ; preds = %136
  br label %146

146:                                              ; preds = %145, %130
  br label %147

147:                                              ; preds = %146, %3
  %148 = load i32, ptr %5, align 4, !tbaa !9
  %149 = getelementptr inbounds %class.R2Grid, ptr %21, i32 0, i32 4
  %150 = getelementptr inbounds [2 x i32], ptr %149, i64 0, i64 0
  store i32 %148, ptr %150, align 8, !tbaa !9
  %151 = load i32, ptr %6, align 4, !tbaa !9
  %152 = getelementptr inbounds %class.R2Grid, ptr %21, i32 0, i32 4
  %153 = getelementptr inbounds [2 x i32], ptr %152, i64 0, i64 1
  store i32 %151, ptr %153, align 4, !tbaa !9
  %154 = load i32, ptr %5, align 4, !tbaa !9
  %155 = getelementptr inbounds %class.R2Grid, ptr %21, i32 0, i32 5
  store i32 %154, ptr %155, align 8, !tbaa !22
  %156 = getelementptr inbounds %class.R2Grid, ptr %21, i32 0, i32 5
  %157 = load i32, ptr %156, align 8, !tbaa !22
  %158 = load i32, ptr %6, align 4, !tbaa !9
  %159 = mul nsw i32 %157, %158
  %160 = getelementptr inbounds %class.R2Grid, ptr %21, i32 0, i32 6
  store i32 %159, ptr %160, align 4, !tbaa !23
  %161 = getelementptr inbounds %class.R2Grid, ptr %21, i32 0, i32 3
  %162 = load ptr, ptr %161, align 8, !tbaa !11
  %163 = icmp ne ptr %162, null
  br i1 %163, label %164, label %170

164:                                              ; preds = %147
  %165 = getelementptr inbounds %class.R2Grid, ptr %21, i32 0, i32 3
  %166 = load ptr, ptr %165, align 8, !tbaa !11
  %167 = icmp eq ptr %166, null
  br i1 %167, label %169, label %168

168:                                              ; preds = %164
  call void @_ZdaPv(ptr noundef %166) #10
  br label %169

169:                                              ; preds = %168, %164
  br label %170

170:                                              ; preds = %169, %147
  %171 = load ptr, ptr %7, align 8, !tbaa !5
  %172 = getelementptr inbounds %class.R2Grid, ptr %21, i32 0, i32 3
  store ptr %171, ptr %172, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 40, ptr %18) #8
  call void @_ZNK6R2Grid8WorldBoxEv(ptr dead_on_unwind writable sret(%class.R2Box) align 8 %18, ptr noundef nonnull align 8 dereferenceable(208) %21)
  invoke void @_ZN6R2Grid28SetWorldToGridTransformationERK5R2Box(ptr noundef nonnull align 8 dereferenceable(208) %21, ptr noundef nonnull align 8 dereferenceable(40) %18)
          to label %173 unwind label %174

173:                                              ; preds = %170
  call void @_ZN7R2SolidD2Ev(ptr noundef nonnull align 8 dereferenceable(40) %18) #8
  call void @llvm.lifetime.end.p0(i64 40, ptr %18) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #8
  ret void

174:                                              ; preds = %170
  %175 = landingpad { ptr, i32 }
          cleanup
  %176 = extractvalue { ptr, i32 } %175, 0
  store ptr %176, ptr %19, align 8
  %177 = extractvalue { ptr, i32 } %175, 1
  store i32 %177, ptr %20, align 4
  call void @_ZN7R2SolidD2Ev(ptr noundef nonnull align 8 dereferenceable(40) %18) #8
  call void @llvm.lifetime.end.p0(i64 40, ptr %18) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #8
  br label %178

178:                                              ; preds = %174
  %179 = load ptr, ptr %19, align 8
  %180 = load i32, ptr %20, align 4
  %181 = insertvalue { ptr, i32 } poison, ptr %179, 0
  %182 = insertvalue { ptr, i32 } %181, i32 %180, 1
  resume { ptr, i32 } %182
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZNK6R2Grid8WorldBoxEv(ptr dead_on_unwind noalias writable sret(%class.R2Box) align 8, ptr noundef nonnull align 8 dereferenceable(208)) #6 align 2

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

attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = { "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 = { 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 = { 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 #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 "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, !6, i64 184}
!12 = !{!"_ZTS6R2Grid", !13, i64 0, !13, i64 88, !16, i64 176, !6, 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 = !{!"double", !7, i64 0}
!17 = !{!16, !16, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = distinct !{!20, !19}
!21 = distinct !{!21, !19}
!22 = !{!12, !10, i64 200}
!23 = !{!12, !10, i64 204}


; 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.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: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) local_unnamed_addr #0

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

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

; 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 #2 align 2

; Function Attrs: nobuiltin nounwind
declare void @_ZdaPv(ptr noundef) local_unnamed_addr #3

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6R2Grid8ResampleEii(ptr noundef nonnull align 8 dereferenceable(208) %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #2 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca %class.R2Box, align 8
  %5 = mul nsw i32 %2, %1
  %6 = icmp sgt i32 %5, 0
  br i1 %6, label %7, label %.loopexit

7:                                                ; preds = %3
  %8 = zext nneg i32 %5 to i64
  %9 = shl nuw nsw i64 %8, 3
  %10 = tail call noalias noundef nonnull ptr @_Znam(i64 noundef %9) #7
  %11 = getelementptr inbounds i8, ptr %0, i64 184
  %12 = load ptr, ptr %11, align 8, !tbaa !5
  %.not = icmp eq ptr %12, null
  br i1 %.not, label %.lr.ph.preheader, label %13

13:                                               ; preds = %7
  %14 = getelementptr inbounds i8, ptr %0, i64 192
  %15 = load i32, ptr %14, align 8, !tbaa !15
  %16 = icmp sgt i32 %15, 0
  br i1 %16, label %17, label %.lr.ph.preheader

17:                                               ; preds = %13
  %18 = getelementptr inbounds i8, ptr %0, i64 196
  %19 = load i32, ptr %18, align 4, !tbaa !15
  %20 = icmp sgt i32 %19, 0
  br i1 %20, label %21, label %.lr.ph.preheader

21:                                               ; preds = %17
  %22 = add nsw i32 %15, -1
  %23 = uitofp nneg i32 %22 to double
  %24 = add nsw i32 %1, -1
  %25 = sitofp i32 %24 to double
  %26 = fdiv double %23, %25
  %27 = add nsw i32 %19, -1
  %28 = uitofp nneg i32 %27 to double
  %29 = add nsw i32 %2, -1
  %30 = sitofp i32 %29 to double
  %31 = fdiv double %28, %30
  %32 = icmp sgt i32 %2, 0
  %33 = icmp sgt i32 %1, 0
  %or.cond = and i1 %32, %33
  br i1 %or.cond, label %.lr.ph52.split.us, label %.loopexit

.lr.ph52.split.us:                                ; preds = %21, %._crit_edge.us
  %.03750.us = phi ptr [ %55, %._crit_edge.us ], [ %10, %21 ]
  %.03949.us = phi i32 [ %57, %._crit_edge.us ], [ 0, %21 ]
  %34 = icmp eq i32 %.03949.us, %29
  br i1 %34, label %38, label %35

35:                                               ; preds = %.lr.ph52.split.us
  %36 = uitofp nneg i32 %.03949.us to double
  %37 = fmul double %31, %36
  br label %.lr.ph.us

38:                                               ; preds = %.lr.ph52.split.us
  %39 = load i32, ptr %18, align 4, !tbaa !15
  %40 = add nsw i32 %39, -1
  %41 = sitofp i32 %40 to double
  br label %.lr.ph.us

.lr.ph.us:                                        ; preds = %38, %35
  %42 = phi double [ %41, %38 ], [ %37, %35 ]
  br label %43

43:                                               ; preds = %.lr.ph.us, %52
  %.148.us = phi ptr [ %.03750.us, %.lr.ph.us ], [ %55, %52 ]
  %.04047.us = phi i32 [ 0, %.lr.ph.us ], [ %56, %52 ]
  %44 = icmp eq i32 %.04047.us, %24
  br i1 %44, label %48, label %45

45:                                               ; preds = %43
  %46 = uitofp nneg i32 %.04047.us to double
  %47 = fmul double %26, %46
  br label %52

48:                                               ; preds = %43
  %49 = load i32, ptr %14, align 8, !tbaa !15
  %50 = add nsw i32 %49, -1
  %51 = sitofp i32 %50 to double
  br label %52

52:                                               ; preds = %48, %45
  %53 = phi double [ %51, %48 ], [ %47, %45 ]
  %54 = tail call noundef double @_ZNK6R2Grid9GridValueEdd(ptr noundef nonnull align 8 dereferenceable(208) %0, double noundef %53, double noundef %42)
  %55 = getelementptr inbounds i8, ptr %.148.us, i64 8
  store double %54, ptr %.148.us, align 8, !tbaa !16
  %56 = add nuw nsw i32 %.04047.us, 1
  %exitcond.not = icmp eq i32 %56, %1
  br i1 %exitcond.not, label %._crit_edge.us, label %43, !llvm.loop !17

._crit_edge.us:                                   ; preds = %52
  %57 = add nuw nsw i32 %.03949.us, 1
  %exitcond56.not = icmp eq i32 %57, %2
  br i1 %exitcond56.not, label %.loopexit, label %.lr.ph52.split.us, !llvm.loop !19

.lr.ph.preheader:                                 ; preds = %7, %13, %17
  %58 = zext nneg i32 %5 to i64
  %59 = shl nuw nsw i64 %58, 3
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(1) %10, i8 0, i64 %59, i1 false), !tbaa !16
  br label %.loopexit

.loopexit:                                        ; preds = %._crit_edge.us, %.lr.ph.preheader, %21, %3
  %.0 = phi ptr [ null, %3 ], [ %10, %21 ], [ %10, %.lr.ph.preheader ], [ %10, %._crit_edge.us ]
  %60 = getelementptr inbounds i8, ptr %0, i64 192
  store i32 %1, ptr %60, align 8, !tbaa !15
  %61 = getelementptr inbounds i8, ptr %0, i64 196
  store i32 %2, ptr %61, align 4, !tbaa !15
  %62 = getelementptr inbounds i8, ptr %0, i64 200
  store i32 %1, ptr %62, align 8, !tbaa !20
  %63 = getelementptr inbounds i8, ptr %0, i64 204
  store i32 %5, ptr %63, align 4, !tbaa !21
  %64 = getelementptr inbounds i8, ptr %0, i64 184
  %65 = load ptr, ptr %64, align 8, !tbaa !5
  %.not45 = icmp eq ptr %65, null
  br i1 %.not45, label %67, label %66

66:                                               ; preds = %.loopexit
  tail call void @_ZdaPv(ptr noundef nonnull %65) #8
  br label %67

67:                                               ; preds = %66, %.loopexit
  store ptr %.0, ptr %64, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 40, ptr nonnull %4) #9
  call void @_ZNK6R2Grid8WorldBoxEv(ptr dead_on_unwind nonnull writable sret(%class.R2Box) align 8 %4, ptr noundef nonnull align 8 dereferenceable(208) %0)
  invoke void @_ZN6R2Grid28SetWorldToGridTransformationERK5R2Box(ptr noundef nonnull align 8 dereferenceable(208) %0, ptr noundef nonnull align 8 dereferenceable(40) %4)
          to label %68 unwind label %69

68:                                               ; preds = %67
  call void @_ZN7R2SolidD2Ev(ptr noundef nonnull align 8 dereferenceable(40) %4) #9
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %4) #9
  ret void

69:                                               ; preds = %67
  %70 = landingpad { ptr, i32 }
          cleanup
  call void @_ZN7R2SolidD2Ev(ptr noundef nonnull align 8 dereferenceable(40) %4) #9
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %4) #9
  resume { ptr, i32 } %70
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZNK6R2Grid8WorldBoxEv(ptr dead_on_unwind noalias writable sret(%class.R2Box) align 8, ptr noundef nonnull align 8 dereferenceable(208)) local_unnamed_addr #4 align 2

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

; 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 = { 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 #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #4 = { 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 #5 = { 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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #7 = { builtin allocsize(0) }
attributes #8 = { builtin nounwind }
attributes #9 = { 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, !14, i64 184}
!6 = !{!"_ZTS6R2Grid", !7, i64 0, !7, i64 88, !13, i64 176, !14, i64 184, !10, i64 192, !12, i64 200, !12, i64 204}
!7 = !{!"_ZTS8R2Affine", !8, i64 0, !9, i64 8, !12, i64 80}
!8 = !{!"_ZTS16R2Transformation"}
!9 = !{!"_ZTS8R3Matrix", !10, i64 0}
!10 = !{!"omnipotent char", !11, i64 0}
!11 = !{!"Simple C++ TBAA"}
!12 = !{!"int", !10, i64 0}
!13 = !{!"double", !10, i64 0}
!14 = !{!"any pointer", !10, i64 0}
!15 = !{!12, !12, i64 0}
!16 = !{!13, !13, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = distinct !{!19, !18}
!20 = !{!6, !12, i64 200}
!21 = !{!6, !12, i64 204}


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