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

; 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

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: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK6R2Grid11XResolutionEv(ptr noundef nonnull align 8 dereferenceable(208)) #4 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK6R2Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(208)) #4 align 2

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6R2Grid11PadWithZeroEii(ptr noundef nonnull align 8 dereferenceable(208) %0, i32 noundef %1, i32 noundef %2) #7 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca %class.R2Grid, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca double, align 8
  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
  %15 = load ptr, ptr %4, align 8
  %16 = call noundef i32 @_ZNK6R2Grid11XResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %15)
  %17 = load i32, ptr %5, align 4, !tbaa !9
  %18 = icmp sge i32 %16, %17
  br i1 %18, label %19, label %24

19:                                               ; preds = %3
  %20 = call noundef i32 @_ZNK6R2Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %15)
  %21 = load i32, ptr %6, align 4, !tbaa !9
  %22 = icmp sge i32 %20, %21
  br i1 %22, label %23, label %24

23:                                               ; preds = %19
  br label %139

24:                                               ; preds = %19, %3
  call void @llvm.lifetime.start.p0(i64 208, ptr %7) #8
  call void @_ZN6R2GridC1ERKS_(ptr noundef nonnull align 8 dereferenceable(208) %7, ptr noundef nonnull align 8 dereferenceable(208) %15)
  %25 = load i32, ptr %5, align 4, !tbaa !9
  %26 = getelementptr inbounds %class.R2Grid, ptr %15, i32 0, i32 4
  %27 = getelementptr inbounds [2 x i32], ptr %26, i64 0, i64 0
  store i32 %25, ptr %27, align 8, !tbaa !9
  %28 = load i32, ptr %6, align 4, !tbaa !9
  %29 = getelementptr inbounds %class.R2Grid, ptr %15, i32 0, i32 4
  %30 = getelementptr inbounds [2 x i32], ptr %29, i64 0, i64 1
  store i32 %28, ptr %30, align 4, !tbaa !9
  %31 = load i32, ptr %5, align 4, !tbaa !9
  %32 = getelementptr inbounds %class.R2Grid, ptr %15, i32 0, i32 5
  store i32 %31, ptr %32, align 8, !tbaa !11
  %33 = getelementptr inbounds %class.R2Grid, ptr %15, i32 0, i32 5
  %34 = load i32, ptr %33, align 8, !tbaa !11
  %35 = load i32, ptr %6, align 4, !tbaa !9
  %36 = mul nsw i32 %34, %35
  %37 = getelementptr inbounds %class.R2Grid, ptr %15, i32 0, i32 6
  store i32 %36, ptr %37, align 4, !tbaa !17
  %38 = getelementptr inbounds %class.R2Grid, ptr %15, i32 0, i32 3
  %39 = load ptr, ptr %38, align 8, !tbaa !18
  %40 = icmp ne ptr %39, null
  br i1 %40, label %41, label %47

41:                                               ; preds = %24
  %42 = getelementptr inbounds %class.R2Grid, ptr %15, i32 0, i32 3
  %43 = load ptr, ptr %42, align 8, !tbaa !18
  %44 = icmp eq ptr %43, null
  br i1 %44, label %46, label %45

45:                                               ; preds = %41
  call void @_ZdaPv(ptr noundef %43) #9
  br label %46

46:                                               ; preds = %45, %41
  br label %47

47:                                               ; preds = %46, %24
  %48 = getelementptr inbounds %class.R2Grid, ptr %15, i32 0, i32 6
  %49 = load i32, ptr %48, align 4, !tbaa !17
  %50 = icmp eq i32 %49, 0
  br i1 %50, label %51, label %53

51:                                               ; preds = %47
  %52 = getelementptr inbounds %class.R2Grid, ptr %15, i32 0, i32 3
  store ptr null, ptr %52, align 8, !tbaa !18
  br label %68

53:                                               ; preds = %47
  %54 = getelementptr inbounds %class.R2Grid, ptr %15, i32 0, i32 6
  %55 = load i32, ptr %54, align 4, !tbaa !17
  %56 = sext i32 %55 to i64
  %57 = call { i64, i1 } @llvm.umul.with.overflow.i64(i64 %56, i64 8)
  %58 = extractvalue { i64, i1 } %57, 1
  %59 = extractvalue { i64, i1 } %57, 0
  %60 = select i1 %58, i64 -1, i64 %59
  %61 = invoke noalias noundef nonnull ptr @_Znam(i64 noundef %60) #10
          to label %62 unwind label %64

62:                                               ; preds = %53
  %63 = getelementptr inbounds %class.R2Grid, ptr %15, i32 0, i32 3
  store ptr %61, ptr %63, align 8, !tbaa !18
  br label %68

64:                                               ; preds = %76, %53
  %65 = landingpad { ptr, i32 }
          cleanup
  %66 = extractvalue { ptr, i32 } %65, 0
  store ptr %66, ptr %8, align 8
  %67 = extractvalue { ptr, i32 } %65, 1
  store i32 %67, ptr %9, align 4
  br label %140

68:                                               ; preds = %62, %51
  %69 = getelementptr inbounds %class.R2Grid, ptr %15, i32 0, i32 6
  %70 = load i32, ptr %69, align 4, !tbaa !17
  %71 = icmp ne i32 %70, 0
  br i1 %71, label %72, label %78

72:                                               ; preds = %68
  %73 = getelementptr inbounds %class.R2Grid, ptr %15, i32 0, i32 3
  %74 = load ptr, ptr %73, align 8, !tbaa !18
  %75 = icmp ne ptr %74, null
  br i1 %75, label %78, label %76

76:                                               ; preds = %72
  invoke void (ptr, ...) @_Z7RNAbortPKcz(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 2077, ptr noundef @.str.2)
          to label %77 unwind label %64

77:                                               ; preds = %76
  br label %78

78:                                               ; preds = %77, %72, %68
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #8
  store i32 0, ptr %10, align 4, !tbaa !9
  br label %79

79:                                               ; preds = %91, %78
  %80 = load i32, ptr %10, align 4, !tbaa !9
  %81 = getelementptr inbounds %class.R2Grid, ptr %15, i32 0, i32 6
  %82 = load i32, ptr %81, align 4, !tbaa !17
  %83 = icmp slt i32 %80, %82
  br i1 %83, label %85, label %84

84:                                               ; preds = %79
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #8
  br label %94

85:                                               ; preds = %79
  %86 = getelementptr inbounds %class.R2Grid, ptr %15, i32 0, i32 3
  %87 = load ptr, ptr %86, align 8, !tbaa !18
  %88 = load i32, ptr %10, align 4, !tbaa !9
  %89 = sext i32 %88 to i64
  %90 = getelementptr inbounds double, ptr %87, i64 %89
  store double 0.000000e+00, ptr %90, align 8, !tbaa !19
  br label %91

91:                                               ; preds = %85
  %92 = load i32, ptr %10, align 4, !tbaa !9
  %93 = add nsw i32 %92, 1
  store i32 %93, ptr %10, align 4, !tbaa !9
  br label %79, !llvm.loop !20

94:                                               ; preds = %84
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #8
  store i32 0, ptr %11, align 4, !tbaa !9
  br label %95

95:                                               ; preds = %134, %94
  %96 = load i32, ptr %11, align 4, !tbaa !9
  %97 = invoke noundef i32 @_ZNK6R2Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %7)
          to label %98 unwind label %101

98:                                               ; preds = %95
  %99 = icmp slt i32 %96, %97
  br i1 %99, label %105, label %100

100:                                              ; preds = %98
  store i32 5, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #8
  br label %138

101:                                              ; preds = %95
  %102 = landingpad { ptr, i32 }
          cleanup
  %103 = extractvalue { ptr, i32 } %102, 0
  store ptr %103, ptr %8, align 8
  %104 = extractvalue { ptr, i32 } %102, 1
  store i32 %104, ptr %9, align 4
  br label %137

105:                                              ; preds = %98
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #8
  store i32 0, ptr %13, align 4, !tbaa !9
  br label %106

106:                                              ; preds = %125, %105
  %107 = load i32, ptr %13, align 4, !tbaa !9
  %108 = invoke noundef i32 @_ZNK6R2Grid11XResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %7)
          to label %109 unwind label %112

109:                                              ; preds = %106
  %110 = icmp slt i32 %107, %108
  br i1 %110, label %116, label %111

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

112:                                              ; preds = %106
  %113 = landingpad { ptr, i32 }
          cleanup
  %114 = extractvalue { ptr, i32 } %113, 0
  store ptr %114, ptr %8, align 8
  %115 = extractvalue { ptr, i32 } %113, 1
  store i32 %115, ptr %9, align 4
  br label %132

116:                                              ; preds = %109
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #8
  %117 = load i32, ptr %13, align 4, !tbaa !9
  %118 = load i32, ptr %11, align 4, !tbaa !9
  %119 = invoke noundef double @_ZNK6R2Grid9GridValueEii(ptr noundef nonnull align 8 dereferenceable(208) %7, i32 noundef %117, i32 noundef %118)
          to label %120 unwind label %128

120:                                              ; preds = %116
  store double %119, ptr %14, align 8, !tbaa !19
  %121 = load i32, ptr %13, align 4, !tbaa !9
  %122 = load i32, ptr %11, align 4, !tbaa !9
  %123 = load double, ptr %14, align 8, !tbaa !19
  invoke void @_ZN6R2Grid12SetGridValueEiid(ptr noundef nonnull align 8 dereferenceable(208) %15, i32 noundef %121, i32 noundef %122, double noundef %123)
          to label %124 unwind label %128

124:                                              ; preds = %120
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #8
  br label %125

125:                                              ; preds = %124
  %126 = load i32, ptr %13, align 4, !tbaa !9
  %127 = add nsw i32 %126, 1
  store i32 %127, ptr %13, align 4, !tbaa !9
  br label %106, !llvm.loop !22

128:                                              ; preds = %120, %116
  %129 = landingpad { ptr, i32 }
          cleanup
  %130 = extractvalue { ptr, i32 } %129, 0
  store ptr %130, ptr %8, align 8
  %131 = extractvalue { ptr, i32 } %129, 1
  store i32 %131, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #8
  br label %132

132:                                              ; preds = %128, %112
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #8
  br label %137

133:                                              ; preds = %111
  br label %134

134:                                              ; preds = %133
  %135 = load i32, ptr %11, align 4, !tbaa !9
  %136 = add nsw i32 %135, 1
  store i32 %136, ptr %11, align 4, !tbaa !9
  br label %95, !llvm.loop !23

137:                                              ; preds = %132, %101
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #8
  br label %140

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

139:                                              ; preds = %138, %23
  ret void

140:                                              ; preds = %137, %64
  call void @_ZN6R2GridD1Ev(ptr noundef nonnull align 8 dereferenceable(208) %7) #8
  call void @llvm.lifetime.end.p0(i64 208, ptr %7) #8
  br label %141

141:                                              ; preds = %140
  %142 = load ptr, ptr %8, align 8
  %143 = load i32, ptr %9, align 4
  %144 = insertvalue { ptr, i32 } poison, ptr %142, 0
  %145 = insertvalue { ptr, i32 } %144, i32 %143, 1
  resume { ptr, i32 } %145
}

declare void @_ZN6R2GridC1ERKS_(ptr, ptr)

declare void @_ZN6R2GridD1Ev(ptr)

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 = { 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 #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 = { 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 = { 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 #8 = { nounwind }
attributes #9 = { builtin nounwind }
attributes #10 = { 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 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 200}
!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 = !{!12, !10, i64 204}
!18 = !{!12, !6, i64 184}
!19 = !{!16, !16, i64 0}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}
!22 = distinct !{!22, !21}
!23 = distinct !{!23, !21}


; 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]] }

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: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK6R2Grid11XResolutionEv(ptr noundef nonnull align 8 dereferenceable(208)) local_unnamed_addr #2 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK6R2Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(208)) local_unnamed_addr #2 align 2

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6R2Grid11PadWithZeroEii(ptr noundef nonnull align 8 dereferenceable(208) %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #5 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca %class.R2Grid, align 8
  %5 = tail call noundef i32 @_ZNK6R2Grid11XResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %0)
  %.not = icmp slt i32 %5, %1
  br i1 %.not, label %8, label %6

6:                                                ; preds = %3
  %7 = tail call noundef i32 @_ZNK6R2Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %0)
  %.not26 = icmp slt i32 %7, %2
  br i1 %.not26, label %8, label %47

8:                                                ; preds = %6, %3
  call void @llvm.lifetime.start.p0(i64 208, ptr nonnull %4) #7
  call void @_ZN6R2GridC1ERKS_(ptr noundef nonnull align 8 dereferenceable(208) %4, ptr noundef nonnull align 8 dereferenceable(208) %0)
  %9 = getelementptr inbounds i8, ptr %0, i64 192
  store i32 %1, ptr %9, align 8, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %0, i64 196
  store i32 %2, ptr %10, align 4, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %0, i64 200
  store i32 %1, ptr %11, align 8, !tbaa !9
  %12 = mul nsw i32 %2, %1
  %13 = getelementptr inbounds i8, ptr %0, i64 204
  store i32 %12, ptr %13, align 4, !tbaa !16
  %14 = getelementptr inbounds i8, ptr %0, i64 184
  %15 = load ptr, ptr %14, align 8, !tbaa !17
  %.not27 = icmp eq ptr %15, null
  br i1 %.not27, label %17, label %16

16:                                               ; preds = %8
  call void @_ZdaPv(ptr noundef nonnull %15) #8
  %.pr = load i32, ptr %13, align 4, !tbaa !16
  br label %17

17:                                               ; preds = %16, %8
  %18 = phi i32 [ %.pr, %16 ], [ %12, %8 ]
  %19 = icmp eq i32 %18, 0
  br i1 %19, label %.thread, label %20

.thread:                                          ; preds = %17
  store ptr null, ptr %14, align 8, !tbaa !17
  br label %.preheader31

20:                                               ; preds = %17
  %21 = sext i32 %18 to i64
  %22 = icmp slt i32 %18, 0
  %23 = shl nsw i64 %21, 3
  %24 = select i1 %22, i64 -1, i64 %23
  %25 = invoke noalias noundef nonnull ptr @_Znam(i64 noundef %24) #9
          to label %28 unwind label %26

26:                                               ; preds = %20
  %27 = landingpad { ptr, i32 }
          cleanup
  br label %48

28:                                               ; preds = %20
  store ptr %25, ptr %14, align 8, !tbaa !17
  %29 = icmp sgt i32 %18, 0
  br i1 %29, label %.lr.ph, label %.preheader31

.lr.ph:                                           ; preds = %28
  %30 = zext nneg i32 %18 to i64
  %31 = shl nuw nsw i64 %30, 3
  call void @llvm.memset.p0.i64(ptr nonnull align 8 %25, i8 0, i64 %31, i1 false), !tbaa !18
  br label %.preheader31

.preheader31:                                     ; preds = %.thread, %.lr.ph, %28
  %32 = call noundef i32 @_ZNK6R2Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %4)
  %33 = icmp sgt i32 %32, 0
  br i1 %33, label %.preheader, label %._crit_edge36

.preheader:                                       ; preds = %.preheader31, %._crit_edge
  %.02135 = phi i32 [ %36, %._crit_edge ], [ 0, %.preheader31 ]
  %34 = call noundef i32 @_ZNK6R2Grid11XResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %4)
  %35 = icmp sgt i32 %34, 0
  br i1 %35, label %.lr.ph34, label %._crit_edge

._crit_edge36:                                    ; preds = %._crit_edge, %.preheader31
  call void @_ZN6R2GridD1Ev(ptr noundef nonnull align 8 dereferenceable(208) %4) #7
  call void @llvm.lifetime.end.p0(i64 208, ptr nonnull %4) #7
  br label %47

._crit_edge:                                      ; preds = %41, %.preheader
  %36 = add nuw nsw i32 %.02135, 1
  %37 = call noundef i32 @_ZNK6R2Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %4)
  %38 = icmp slt i32 %36, %37
  br i1 %38, label %.preheader, label %._crit_edge36, !llvm.loop !19

.lr.ph34:                                         ; preds = %.preheader, %41
  %.02033 = phi i32 [ %42, %41 ], [ 0, %.preheader ]
  %39 = invoke noundef double @_ZNK6R2Grid9GridValueEii(ptr noundef nonnull align 8 dereferenceable(208) %4, i32 noundef %.02033, i32 noundef %.02135)
          to label %40 unwind label %45

40:                                               ; preds = %.lr.ph34
  invoke void @_ZN6R2Grid12SetGridValueEiid(ptr noundef nonnull align 8 dereferenceable(208) %0, i32 noundef %.02033, i32 noundef %.02135, double noundef %39)
          to label %41 unwind label %45

41:                                               ; preds = %40
  %42 = add nuw nsw i32 %.02033, 1
  %43 = call noundef i32 @_ZNK6R2Grid11XResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %4)
  %44 = icmp slt i32 %42, %43
  br i1 %44, label %.lr.ph34, label %._crit_edge, !llvm.loop !21

45:                                               ; preds = %40, %.lr.ph34
  %46 = landingpad { ptr, i32 }
          cleanup
  br label %48

47:                                               ; preds = %6, %._crit_edge36
  ret void

48:                                               ; preds = %45, %26
  %.pn = phi { ptr, i32 } [ %46, %45 ], [ %27, %26 ]
  call void @_ZN6R2GridD1Ev(ptr noundef nonnull align 8 dereferenceable(208) %4) #7
  call void @llvm.lifetime.end.p0(i64 208, ptr nonnull %4) #7
  resume { ptr, i32 } %.pn
}

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


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