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

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

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 @_ZNK6R2Grid9GridValueEii(ptr noundef nonnull align 8 dereferenceable(208), i32 noundef, i32 noundef) #1 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) #1 align 2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN6R2Grid9NormalizeEv(ptr noundef nonnull align 8 dereferenceable(208)) #3 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6R2Grid22PointSymmetryTransformEi(ptr noundef nonnull align 8 dereferenceable(208) %0, i32 noundef %1) #3 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca %class.R2Grid, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca double, align 8
  %14 = alloca double, align 8
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca double, align 8
  %18 = alloca double, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  %19 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 208, ptr %5) #4
  call void @_ZN6R2GridC1ERKS_(ptr noundef nonnull align 8 dereferenceable(208) %5, ptr noundef nonnull align 8 dereferenceable(208) %19)
  invoke void @_ZN6R2Grid9NormalizeEv(ptr noundef nonnull align 8 dereferenceable(208) %5)
          to label %20 unwind label %28

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

21:                                               ; preds = %175, %20
  %22 = load i32, ptr %8, align 4, !tbaa !9
  %23 = getelementptr inbounds %class.R2Grid, ptr %19, i32 0, i32 4
  %24 = getelementptr inbounds [2 x i32], ptr %23, i64 0, i64 1
  %25 = load i32, ptr %24, align 4, !tbaa !9
  %26 = icmp slt i32 %22, %25
  br i1 %26, label %32, label %27

27:                                               ; preds = %21
  store i32 2, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  br label %178

28:                                               ; preds = %2
  %29 = landingpad { ptr, i32 }
          cleanup
  %30 = extractvalue { ptr, i32 } %29, 0
  store ptr %30, ptr %6, align 8
  %31 = extractvalue { ptr, i32 } %29, 1
  store i32 %31, ptr %7, align 4
  br label %179

32:                                               ; preds = %21
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  %33 = load i32, ptr %8, align 4, !tbaa !9
  %34 = getelementptr inbounds %class.R2Grid, ptr %19, i32 0, i32 4
  %35 = getelementptr inbounds [2 x i32], ptr %34, i64 0, i64 1
  %36 = load i32, ptr %35, align 4, !tbaa !9
  %37 = sdiv i32 %36, 2
  %38 = icmp slt i32 %33, %37
  br i1 %38, label %39, label %41

39:                                               ; preds = %32
  %40 = load i32, ptr %8, align 4, !tbaa !9
  br label %48

41:                                               ; preds = %32
  %42 = getelementptr inbounds %class.R2Grid, ptr %19, i32 0, i32 4
  %43 = getelementptr inbounds [2 x i32], ptr %42, i64 0, i64 1
  %44 = load i32, ptr %43, align 4, !tbaa !9
  %45 = sub nsw i32 %44, 1
  %46 = load i32, ptr %8, align 4, !tbaa !9
  %47 = sub nsw i32 %45, %46
  br label %48

48:                                               ; preds = %41, %39
  %49 = phi i32 [ %40, %39 ], [ %47, %41 ]
  store i32 %49, ptr %10, align 4, !tbaa !9
  %50 = load i32, ptr %4, align 4, !tbaa !9
  %51 = icmp sgt i32 %50, 0
  br i1 %51, label %52, label %58

52:                                               ; preds = %48
  %53 = load i32, ptr %10, align 4, !tbaa !9
  %54 = load i32, ptr %4, align 4, !tbaa !9
  %55 = icmp sgt i32 %53, %54
  br i1 %55, label %56, label %58

56:                                               ; preds = %52
  %57 = load i32, ptr %4, align 4, !tbaa !9
  store i32 %57, ptr %10, align 4, !tbaa !9
  br label %58

58:                                               ; preds = %56, %52, %48
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  store i32 0, ptr %11, align 4, !tbaa !9
  br label %59

59:                                               ; preds = %166, %58
  %60 = load i32, ptr %11, align 4, !tbaa !9
  %61 = getelementptr inbounds %class.R2Grid, ptr %19, i32 0, i32 4
  %62 = getelementptr inbounds [2 x i32], ptr %61, i64 0, i64 0
  %63 = load i32, ptr %62, align 8, !tbaa !9
  %64 = icmp slt i32 %60, %63
  br i1 %64, label %66, label %65

65:                                               ; preds = %59
  store i32 5, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  br label %174

66:                                               ; preds = %59
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  %67 = load i32, ptr %11, align 4, !tbaa !9
  %68 = getelementptr inbounds %class.R2Grid, ptr %19, i32 0, i32 4
  %69 = getelementptr inbounds [2 x i32], ptr %68, i64 0, i64 0
  %70 = load i32, ptr %69, align 8, !tbaa !9
  %71 = sdiv i32 %70, 2
  %72 = icmp slt i32 %67, %71
  br i1 %72, label %73, label %75

73:                                               ; preds = %66
  %74 = load i32, ptr %11, align 4, !tbaa !9
  br label %82

75:                                               ; preds = %66
  %76 = getelementptr inbounds %class.R2Grid, ptr %19, i32 0, i32 4
  %77 = getelementptr inbounds [2 x i32], ptr %76, i64 0, i64 0
  %78 = load i32, ptr %77, align 8, !tbaa !9
  %79 = sub nsw i32 %78, 1
  %80 = load i32, ptr %11, align 4, !tbaa !9
  %81 = sub nsw i32 %79, %80
  br label %82

82:                                               ; preds = %75, %73
  %83 = phi i32 [ %74, %73 ], [ %81, %75 ]
  store i32 %83, ptr %12, align 4, !tbaa !9
  %84 = load i32, ptr %4, align 4, !tbaa !9
  %85 = icmp sgt i32 %84, 0
  br i1 %85, label %86, label %92

86:                                               ; preds = %82
  %87 = load i32, ptr %12, align 4, !tbaa !9
  %88 = load i32, ptr %4, align 4, !tbaa !9
  %89 = icmp sgt i32 %87, %88
  br i1 %89, label %90, label %92

90:                                               ; preds = %86
  %91 = load i32, ptr %4, align 4, !tbaa !9
  store i32 %91, ptr %12, align 4, !tbaa !9
  br label %92

92:                                               ; preds = %90, %86, %82
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  store double 0.000000e+00, ptr %13, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  store double 0.000000e+00, ptr %14, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #4
  %93 = load i32, ptr %10, align 4, !tbaa !9
  %94 = sub nsw i32 0, %93
  store i32 %94, ptr %15, align 4, !tbaa !9
  br label %95

95:                                               ; preds = %151, %92
  %96 = load i32, ptr %15, align 4, !tbaa !9
  %97 = load i32, ptr %10, align 4, !tbaa !9
  %98 = icmp sle i32 %96, %97
  br i1 %98, label %100, label %99

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

100:                                              ; preds = %95
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #4
  %101 = load i32, ptr %12, align 4, !tbaa !9
  %102 = sub nsw i32 0, %101
  store i32 %102, ptr %16, align 4, !tbaa !9
  br label %103

103:                                              ; preds = %138, %100
  %104 = load i32, ptr %16, align 4, !tbaa !9
  %105 = load i32, ptr %12, align 4, !tbaa !9
  %106 = icmp sle i32 %104, %105
  br i1 %106, label %108, label %107

107:                                              ; preds = %103
  store i32 11, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #4
  br label %150

108:                                              ; preds = %103
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #4
  %109 = load i32, ptr %11, align 4, !tbaa !9
  %110 = load i32, ptr %16, align 4, !tbaa !9
  %111 = sub nsw i32 %109, %110
  %112 = load i32, ptr %8, align 4, !tbaa !9
  %113 = load i32, ptr %15, align 4, !tbaa !9
  %114 = sub nsw i32 %112, %113
  %115 = invoke noundef double @_ZNK6R2Grid9GridValueEii(ptr noundef nonnull align 8 dereferenceable(208) %19, i32 noundef %111, i32 noundef %114)
          to label %116 unwind label %141

116:                                              ; preds = %108
  store double %115, ptr %17, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #4
  %117 = load i32, ptr %11, align 4, !tbaa !9
  %118 = load i32, ptr %16, align 4, !tbaa !9
  %119 = add nsw i32 %117, %118
  %120 = load i32, ptr %8, align 4, !tbaa !9
  %121 = load i32, ptr %15, align 4, !tbaa !9
  %122 = add nsw i32 %120, %121
  %123 = invoke noundef double @_ZNK6R2Grid9GridValueEii(ptr noundef nonnull align 8 dereferenceable(208) %19, i32 noundef %119, i32 noundef %122)
          to label %124 unwind label %145

124:                                              ; preds = %116
  store double %123, ptr %18, align 8, !tbaa !11
  %125 = load double, ptr %17, align 8, !tbaa !11
  %126 = fmul double 2.000000e+00, %125
  %127 = load double, ptr %18, align 8, !tbaa !11
  %128 = load double, ptr %13, align 8, !tbaa !11
  %129 = call double @llvm.fmuladd.f64(double %126, double %127, double %128)
  store double %129, ptr %13, align 8, !tbaa !11
  %130 = load double, ptr %17, align 8, !tbaa !11
  %131 = load double, ptr %17, align 8, !tbaa !11
  %132 = load double, ptr %14, align 8, !tbaa !11
  %133 = call double @llvm.fmuladd.f64(double %130, double %131, double %132)
  store double %133, ptr %14, align 8, !tbaa !11
  %134 = load double, ptr %18, align 8, !tbaa !11
  %135 = load double, ptr %18, align 8, !tbaa !11
  %136 = load double, ptr %14, align 8, !tbaa !11
  %137 = call double @llvm.fmuladd.f64(double %134, double %135, double %136)
  store double %137, ptr %14, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #4
  br label %138

138:                                              ; preds = %124
  %139 = load i32, ptr %16, align 4, !tbaa !9
  %140 = add nsw i32 %139, 1
  store i32 %140, ptr %16, align 4, !tbaa !9
  br label %103, !llvm.loop !13

141:                                              ; preds = %108
  %142 = landingpad { ptr, i32 }
          cleanup
  %143 = extractvalue { ptr, i32 } %142, 0
  store ptr %143, ptr %6, align 8
  %144 = extractvalue { ptr, i32 } %142, 1
  store i32 %144, ptr %7, align 4
  br label %149

145:                                              ; preds = %116
  %146 = landingpad { ptr, i32 }
          cleanup
  %147 = extractvalue { ptr, i32 } %146, 0
  store ptr %147, ptr %6, align 8
  %148 = extractvalue { ptr, i32 } %146, 1
  store i32 %148, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #4
  br label %149

149:                                              ; preds = %145, %141
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #4
  br label %173

150:                                              ; preds = %107
  br label %151

151:                                              ; preds = %150
  %152 = load i32, ptr %15, align 4, !tbaa !9
  %153 = add nsw i32 %152, 1
  store i32 %153, ptr %15, align 4, !tbaa !9
  br label %95, !llvm.loop !15

154:                                              ; preds = %99
  %155 = load double, ptr %14, align 8, !tbaa !11
  %156 = fcmp ogt double %155, 0.000000e+00
  br i1 %156, label %157, label %161

157:                                              ; preds = %154
  %158 = load double, ptr %14, align 8, !tbaa !11
  %159 = load double, ptr %13, align 8, !tbaa !11
  %160 = fdiv double %159, %158
  store double %160, ptr %13, align 8, !tbaa !11
  br label %161

161:                                              ; preds = %157, %154
  %162 = load i32, ptr %11, align 4, !tbaa !9
  %163 = load i32, ptr %8, align 4, !tbaa !9
  %164 = load double, ptr %13, align 8, !tbaa !11
  invoke void @_ZN6R2Grid12SetGridValueEiid(ptr noundef nonnull align 8 dereferenceable(208) %19, i32 noundef %162, i32 noundef %163, double noundef %164)
          to label %165 unwind label %169

165:                                              ; preds = %161
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  br label %166

166:                                              ; preds = %165
  %167 = load i32, ptr %11, align 4, !tbaa !9
  %168 = add nsw i32 %167, 1
  store i32 %168, ptr %11, align 4, !tbaa !9
  br label %59, !llvm.loop !16

169:                                              ; preds = %161
  %170 = landingpad { ptr, i32 }
          cleanup
  %171 = extractvalue { ptr, i32 } %170, 0
  store ptr %171, ptr %6, align 8
  %172 = extractvalue { ptr, i32 } %170, 1
  store i32 %172, ptr %7, align 4
  br label %173

173:                                              ; preds = %169, %149
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  br label %179

174:                                              ; preds = %65
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  br label %175

175:                                              ; preds = %174
  %176 = load i32, ptr %8, align 4, !tbaa !9
  %177 = add nsw i32 %176, 1
  store i32 %177, ptr %8, align 4, !tbaa !9
  br label %21, !llvm.loop !17

178:                                              ; preds = %27
  call void @_ZN6R2GridD1Ev(ptr noundef nonnull align 8 dereferenceable(208) %5) #4
  call void @llvm.lifetime.end.p0(i64 208, ptr %5) #4
  ret void

179:                                              ; preds = %173, %28
  call void @_ZN6R2GridD1Ev(ptr noundef nonnull align 8 dereferenceable(208) %5) #4
  call void @llvm.lifetime.end.p0(i64 208, ptr %5) #4
  br label %180

180:                                              ; preds = %179
  %181 = load ptr, ptr %6, align 8
  %182 = load i32, ptr %7, align 4
  %183 = insertvalue { ptr, i32 } poison, ptr %181, 0
  %184 = insertvalue { ptr, i32 } %183, i32 %182, 1
  resume { ptr, i32 } %184
}

declare void @_ZN6R2GridC1ERKS_(ptr, ptr)

declare void @_ZN6R2GridD1Ev(ptr)

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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { 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}
!16 = distinct !{!16, !14}
!17 = distinct !{!17, !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.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: 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 @_ZNK6R2Grid9GridValueEii(ptr noundef nonnull align 8 dereferenceable(208), i32 noundef, i32 noundef) local_unnamed_addr #1 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 #1 align 2

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN6R2Grid9NormalizeEv(ptr noundef nonnull align 8 dereferenceable(208)) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6R2Grid22PointSymmetryTransformEi(ptr noundef nonnull align 8 dereferenceable(208) %0, i32 noundef %1) local_unnamed_addr #3 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca %class.R2Grid, align 8
  call void @llvm.lifetime.start.p0(i64 208, ptr nonnull %3) #5
  call void @_ZN6R2GridC1ERKS_(ptr noundef nonnull align 8 dereferenceable(208) %3, ptr noundef nonnull align 8 dereferenceable(208) %0)
  invoke void @_ZN6R2Grid9NormalizeEv(ptr noundef nonnull align 8 dereferenceable(208) %3)
          to label %.preheader unwind label %11

.preheader:                                       ; preds = %2
  %4 = getelementptr inbounds i8, ptr %0, i64 192
  %5 = getelementptr inbounds i8, ptr %0, i64 196
  %6 = load i32, ptr %5, align 4, !tbaa !5
  %7 = icmp sgt i32 %6, 0
  br i1 %7, label %.lr.ph107, label %._crit_edge108

.lr.ph107:                                        ; preds = %.preheader
  %8 = icmp sgt i32 %1, 0
  %9 = load i32, ptr %4, align 8, !tbaa !5
  %10 = icmp sgt i32 %9, 0
  br i1 %10, label %.lr.ph107.split, label %._crit_edge108

._crit_edge108:                                   ; preds = %._crit_edge103, %.lr.ph107, %.preheader
  call void @_ZN6R2GridD1Ev(ptr noundef nonnull align 8 dereferenceable(208) %3) #5
  call void @llvm.lifetime.end.p0(i64 208, ptr nonnull %3) #5
  ret void

11:                                               ; preds = %2
  %12 = landingpad { ptr, i32 }
          cleanup
  br label %66

.lr.ph107.split:                                  ; preds = %.lr.ph107, %._crit_edge103
  %13 = phi i32 [ %28, %._crit_edge103 ], [ %9, %.lr.ph107 ]
  %14 = phi i32 [ %30, %._crit_edge103 ], [ %6, %.lr.ph107 ]
  %.064105 = phi i32 [ %29, %._crit_edge103 ], [ 0, %.lr.ph107 ]
  %15 = sdiv i32 %14, 2
  %16 = icmp slt i32 %.064105, %15
  %17 = xor i32 %.064105, -1
  %18 = add i32 %14, %17
  %19 = select i1 %16, i32 %.064105, i32 %18
  %20 = call i32 @llvm.smin.i32(i32 %19, i32 %1)
  %.063 = select i1 %8, i32 %20, i32 %19
  %21 = icmp sgt i32 %13, 0
  br i1 %21, label %.lr.ph102, label %._crit_edge103

.lr.ph102:                                        ; preds = %.lr.ph107.split
  %22 = sub nsw i32 0, %.063
  %.not89 = icmp slt i32 %.063, 0
  br i1 %.not89, label %.lr.ph102.split.us, label %.lr.ph94

.lr.ph102.split.us:                               ; preds = %.lr.ph102, %23
  %.06299.us = phi i32 [ %24, %23 ], [ 0, %.lr.ph102 ]
  invoke void @_ZN6R2Grid12SetGridValueEiid(ptr noundef nonnull align 8 dereferenceable(208) %0, i32 noundef %.06299.us, i32 noundef %.064105, double noundef 0.000000e+00)
          to label %23 unwind label %.split.us

23:                                               ; preds = %.lr.ph102.split.us
  %24 = add nuw nsw i32 %.06299.us, 1
  %25 = load i32, ptr %4, align 8, !tbaa !5
  %26 = icmp slt i32 %24, %25
  br i1 %26, label %.lr.ph102.split.us, label %._crit_edge103, !llvm.loop !9

.split.us:                                        ; preds = %.lr.ph102.split.us
  %27 = landingpad { ptr, i32 }
          cleanup
  br label %66

._crit_edge103:                                   ; preds = %61, %23, %.lr.ph107.split
  %28 = phi i32 [ %13, %.lr.ph107.split ], [ %25, %23 ], [ %63, %61 ]
  %29 = add nuw nsw i32 %.064105, 1
  %30 = load i32, ptr %5, align 4, !tbaa !5
  %31 = icmp slt i32 %29, %30
  br i1 %31, label %.lr.ph107.split, label %._crit_edge108, !llvm.loop !11

.lr.ph94:                                         ; preds = %.lr.ph102, %61
  %32 = phi i32 [ %63, %61 ], [ %13, %.lr.ph102 ]
  %.06299 = phi i32 [ %62, %61 ], [ 0, %.lr.ph102 ]
  %33 = sdiv i32 %32, 2
  %34 = icmp slt i32 %.06299, %33
  %35 = xor i32 %.06299, -1
  %36 = add i32 %32, %35
  %37 = select i1 %34, i32 %.06299, i32 %36
  %38 = call i32 @llvm.smin.i32(i32 %37, i32 %1)
  %.061 = select i1 %8, i32 %38, i32 %37
  %39 = sub nsw i32 0, %.061
  %.not7184 = icmp slt i32 %.061, 0
  br i1 %.not7184, label %._crit_edge95, label %.lr.ph

._crit_edge95:                                    ; preds = %._crit_edge, %.lr.ph94
  %.us-phi = phi double [ 0.000000e+00, %.lr.ph94 ], [ %53, %._crit_edge ]
  %.us-phi98 = phi double [ 0.000000e+00, %.lr.ph94 ], [ %55, %._crit_edge ]
  %40 = fcmp ogt double %.us-phi98, 0.000000e+00
  %41 = fdiv double %.us-phi, %.us-phi98
  %.260 = select i1 %40, double %41, double %.us-phi
  invoke void @_ZN6R2Grid12SetGridValueEiid(ptr noundef nonnull align 8 dereferenceable(208) %0, i32 noundef %.06299, i32 noundef %.064105, double noundef %.260)
          to label %61 unwind label %.split

.lr.ph:                                           ; preds = %.lr.ph94, %._crit_edge
  %.05592 = phi i32 [ %44, %._crit_edge ], [ %22, %.lr.ph94 ]
  %.05691 = phi double [ %55, %._crit_edge ], [ 0.000000e+00, %.lr.ph94 ]
  %.05890 = phi double [ %53, %._crit_edge ], [ 0.000000e+00, %.lr.ph94 ]
  %42 = sub nsw i32 %.064105, %.05592
  %43 = add nsw i32 %.05592, %.064105
  br label %45

._crit_edge:                                      ; preds = %51
  %44 = add i32 %.05592, 1
  %exitcond113.not = icmp eq i32 %.05592, %.063
  br i1 %exitcond113.not, label %._crit_edge95, label %.lr.ph, !llvm.loop !13

45:                                               ; preds = %.lr.ph, %51
  %.05487 = phi i32 [ %39, %.lr.ph ], [ %56, %51 ]
  %.15786 = phi double [ %.05691, %.lr.ph ], [ %55, %51 ]
  %.15985 = phi double [ %.05890, %.lr.ph ], [ %53, %51 ]
  %46 = sub nsw i32 %.06299, %.05487
  %47 = invoke noundef double @_ZNK6R2Grid9GridValueEii(ptr noundef nonnull align 8 dereferenceable(208) %0, i32 noundef %46, i32 noundef %42)
          to label %48 unwind label %57

48:                                               ; preds = %45
  %49 = add nsw i32 %.05487, %.06299
  %50 = invoke noundef double @_ZNK6R2Grid9GridValueEii(ptr noundef nonnull align 8 dereferenceable(208) %0, i32 noundef %49, i32 noundef %43)
          to label %51 unwind label %59

51:                                               ; preds = %48
  %52 = fmul double %47, 2.000000e+00
  %53 = call double @llvm.fmuladd.f64(double %52, double %50, double %.15985)
  %54 = call double @llvm.fmuladd.f64(double %47, double %47, double %.15786)
  %55 = call double @llvm.fmuladd.f64(double %50, double %50, double %54)
  %56 = add i32 %.05487, 1
  %exitcond.not = icmp eq i32 %.05487, %.061
  br i1 %exitcond.not, label %._crit_edge, label %45, !llvm.loop !14

57:                                               ; preds = %45
  %58 = landingpad { ptr, i32 }
          cleanup
  br label %66

59:                                               ; preds = %48
  %60 = landingpad { ptr, i32 }
          cleanup
  br label %66

61:                                               ; preds = %._crit_edge95
  %62 = add nuw nsw i32 %.06299, 1
  %63 = load i32, ptr %4, align 8, !tbaa !5
  %64 = icmp slt i32 %62, %63
  br i1 %64, label %.lr.ph94, label %._crit_edge103, !llvm.loop !9

.split:                                           ; preds = %._crit_edge95
  %65 = landingpad { ptr, i32 }
          cleanup
  br label %66

66:                                               ; preds = %.split, %.split.us, %59, %57, %11
  %.pn.pn.pn = phi { ptr, i32 } [ %12, %11 ], [ %60, %59 ], [ %58, %57 ], [ %65, %.split ], [ %27, %.split.us ]
  call void @_ZN6R2GridD1Ev(ptr noundef nonnull align 8 dereferenceable(208) %3) #5
  call void @llvm.lifetime.end.p0(i64 208, ptr nonnull %3) #5
  resume { ptr, i32 } %.pn.pn.pn
}

declare void @_ZN6R2GridC1ERKS_(ptr, ptr) local_unnamed_addr

declare void @_ZN6R2GridD1Ev(ptr) local_unnamed_addr

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smin.i32(i32, i32) #4

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 nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10, !12}
!12 = !{!"llvm.loop.unswitch.partial.disable"}
!13 = distinct !{!13, !10}
!14 = distinct !{!14, !10}


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