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

; 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.R2Image = type { i32, i32, i32, i32, ptr }

@.str = external hidden unnamed_addr constant [41 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [89 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [41 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [41 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [40 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [40 x i8], align 1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #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.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN7R2ImageC2ERK6R2GridS2_S2_(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull align 8 dereferenceable(208) %1, ptr noundef nonnull align 8 dereferenceable(208) %2, ptr noundef nonnull align 8 dereferenceable(208) %3) unnamed_addr #3 align 2 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, 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
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  store ptr %3, ptr %8, align 8, !tbaa !5
  %14 = load ptr, ptr %5, align 8
  %15 = getelementptr inbounds %class.R2Image, ptr %14, i32 0, i32 0
  %16 = load ptr, ptr %6, align 8, !tbaa !5
  %17 = call noundef i32 @_ZNK6R2Grid11XResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %16)
  store i32 %17, ptr %15, align 8, !tbaa !9
  %18 = getelementptr inbounds %class.R2Image, ptr %14, i32 0, i32 1
  %19 = load ptr, ptr %6, align 8, !tbaa !5
  %20 = call noundef i32 @_ZNK6R2Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %19)
  store i32 %20, ptr %18, align 4, !tbaa !12
  %21 = getelementptr inbounds %class.R2Image, ptr %14, i32 0, i32 2
  store i32 3, ptr %21, align 8, !tbaa !13
  %22 = getelementptr inbounds %class.R2Image, ptr %14, i32 0, i32 3
  store i32 0, ptr %22, align 4, !tbaa !14
  %23 = getelementptr inbounds %class.R2Image, ptr %14, i32 0, i32 4
  store ptr null, ptr %23, align 8, !tbaa !15
  %24 = load ptr, ptr %6, align 8, !tbaa !5
  %25 = call noundef i32 @_ZNK6R2Grid11XResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %24)
  %26 = load ptr, ptr %7, align 8, !tbaa !5
  %27 = call noundef i32 @_ZNK6R2Grid11XResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %26)
  %28 = icmp ne i32 %25, %27
  br i1 %28, label %30, label %29

29:                                               ; preds = %4
  call void (ptr, ...) @_Z7RNAbortPKcz(ptr noundef @.str, ptr noundef @.str.3, i32 noundef 91, ptr noundef @.str.2)
  br label %30

30:                                               ; preds = %29, %4
  %31 = load ptr, ptr %6, align 8, !tbaa !5
  %32 = call noundef i32 @_ZNK6R2Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %31)
  %33 = load ptr, ptr %7, align 8, !tbaa !5
  %34 = call noundef i32 @_ZNK6R2Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %33)
  %35 = icmp ne i32 %32, %34
  br i1 %35, label %37, label %36

36:                                               ; preds = %30
  call void (ptr, ...) @_Z7RNAbortPKcz(ptr noundef @.str, ptr noundef @.str.4, i32 noundef 92, ptr noundef @.str.2)
  br label %37

37:                                               ; preds = %36, %30
  %38 = load ptr, ptr %6, align 8, !tbaa !5
  %39 = call noundef i32 @_ZNK6R2Grid11XResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %38)
  %40 = load ptr, ptr %8, align 8, !tbaa !5
  %41 = call noundef i32 @_ZNK6R2Grid11XResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %40)
  %42 = icmp ne i32 %39, %41
  br i1 %42, label %44, label %43

43:                                               ; preds = %37
  call void (ptr, ...) @_Z7RNAbortPKcz(ptr noundef @.str, ptr noundef @.str.5, i32 noundef 93, ptr noundef @.str.2)
  br label %44

44:                                               ; preds = %43, %37
  %45 = load ptr, ptr %6, align 8, !tbaa !5
  %46 = call noundef i32 @_ZNK6R2Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %45)
  %47 = load ptr, ptr %8, align 8, !tbaa !5
  %48 = call noundef i32 @_ZNK6R2Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %47)
  %49 = icmp ne i32 %46, %48
  br i1 %49, label %51, label %50

50:                                               ; preds = %44
  call void (ptr, ...) @_Z7RNAbortPKcz(ptr noundef @.str, ptr noundef @.str.6, i32 noundef 94, ptr noundef @.str.2)
  br label %51

51:                                               ; preds = %50, %44
  %52 = getelementptr inbounds %class.R2Image, ptr %14, i32 0, i32 2
  %53 = load i32, ptr %52, align 8, !tbaa !13
  %54 = getelementptr inbounds %class.R2Image, ptr %14, i32 0, i32 0
  %55 = load i32, ptr %54, align 8, !tbaa !9
  %56 = mul nsw i32 %53, %55
  %57 = getelementptr inbounds %class.R2Image, ptr %14, i32 0, i32 3
  store i32 %56, ptr %57, align 4, !tbaa !14
  %58 = getelementptr inbounds %class.R2Image, ptr %14, i32 0, i32 3
  %59 = load i32, ptr %58, align 4, !tbaa !14
  %60 = srem i32 %59, 4
  %61 = icmp ne i32 %60, 0
  br i1 %61, label %62, label %69

62:                                               ; preds = %51
  %63 = getelementptr inbounds %class.R2Image, ptr %14, i32 0, i32 3
  %64 = load i32, ptr %63, align 4, !tbaa !14
  %65 = sdiv i32 %64, 4
  %66 = add nsw i32 %65, 1
  %67 = mul nsw i32 %66, 4
  %68 = getelementptr inbounds %class.R2Image, ptr %14, i32 0, i32 3
  store i32 %67, ptr %68, align 4, !tbaa !14
  br label %69

69:                                               ; preds = %62, %51
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #6
  %70 = getelementptr inbounds %class.R2Image, ptr %14, i32 0, i32 3
  %71 = load i32, ptr %70, align 4, !tbaa !14
  %72 = getelementptr inbounds %class.R2Image, ptr %14, i32 0, i32 1
  %73 = load i32, ptr %72, align 4, !tbaa !12
  %74 = mul nsw i32 %71, %73
  store i32 %74, ptr %9, align 4, !tbaa !16
  %75 = load i32, ptr %9, align 4, !tbaa !16
  %76 = icmp sgt i32 %75, 0
  br i1 %76, label %77, label %182

77:                                               ; preds = %69
  %78 = load i32, ptr %9, align 4, !tbaa !16
  %79 = sext i32 %78 to i64
  %80 = call noalias noundef nonnull ptr @_Znam(i64 noundef %79) #7
  %81 = getelementptr inbounds %class.R2Image, ptr %14, i32 0, i32 4
  store ptr %80, ptr %81, align 8, !tbaa !15
  %82 = getelementptr inbounds %class.R2Image, ptr %14, i32 0, i32 4
  %83 = load ptr, ptr %82, align 8, !tbaa !15
  %84 = icmp ne ptr %83, null
  br i1 %84, label %86, label %85

85:                                               ; preds = %77
  call void (ptr, ...) @_Z7RNAbortPKcz(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 102, ptr noundef @.str.2)
  br label %86

86:                                               ; preds = %85, %77
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  store i32 0, ptr %10, align 4, !tbaa !16
  br label %87

87:                                               ; preds = %178, %86
  %88 = load i32, ptr %10, align 4, !tbaa !16
  %89 = getelementptr inbounds %class.R2Image, ptr %14, i32 0, i32 0
  %90 = load i32, ptr %89, align 8, !tbaa !9
  %91 = getelementptr inbounds %class.R2Image, ptr %14, i32 0, i32 1
  %92 = load i32, ptr %91, align 4, !tbaa !12
  %93 = mul nsw i32 %90, %92
  %94 = icmp slt i32 %88, %93
  br i1 %94, label %96, label %95

95:                                               ; preds = %87
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  br label %181

96:                                               ; preds = %87
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #6
  %97 = load ptr, ptr %6, align 8, !tbaa !5
  %98 = load i32, ptr %10, align 4, !tbaa !16
  %99 = call noundef double @_ZNK6R2Grid9GridValueEi(ptr noundef nonnull align 8 dereferenceable(208) %97, i32 noundef %98)
  %100 = fmul double 2.550000e+02, %99
  %101 = fptosi double %100 to i32
  store i32 %101, ptr %11, align 4, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #6
  %102 = load ptr, ptr %7, align 8, !tbaa !5
  %103 = load i32, ptr %10, align 4, !tbaa !16
  %104 = call noundef double @_ZNK6R2Grid9GridValueEi(ptr noundef nonnull align 8 dereferenceable(208) %102, i32 noundef %103)
  %105 = fmul double 2.550000e+02, %104
  %106 = fptosi double %105 to i32
  store i32 %106, ptr %12, align 4, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #6
  %107 = load ptr, ptr %8, align 8, !tbaa !5
  %108 = load i32, ptr %10, align 4, !tbaa !16
  %109 = call noundef double @_ZNK6R2Grid9GridValueEi(ptr noundef nonnull align 8 dereferenceable(208) %107, i32 noundef %108)
  %110 = fmul double 2.550000e+02, %109
  %111 = fptosi double %110 to i32
  store i32 %111, ptr %13, align 4, !tbaa !16
  %112 = load i32, ptr %11, align 4, !tbaa !16
  %113 = icmp slt i32 %112, 0
  br i1 %113, label %114, label %115

114:                                              ; preds = %96
  br label %123

115:                                              ; preds = %96
  %116 = load i32, ptr %11, align 4, !tbaa !16
  %117 = icmp sgt i32 %116, 255
  br i1 %117, label %118, label %119

118:                                              ; preds = %115
  br label %121

119:                                              ; preds = %115
  %120 = load i32, ptr %11, align 4, !tbaa !16
  br label %121

121:                                              ; preds = %119, %118
  %122 = phi i32 [ 255, %118 ], [ %120, %119 ]
  br label %123

123:                                              ; preds = %121, %114
  %124 = phi i32 [ 0, %114 ], [ %122, %121 ]
  store i32 %124, ptr %11, align 4, !tbaa !16
  %125 = load i32, ptr %12, align 4, !tbaa !16
  %126 = icmp slt i32 %125, 0
  br i1 %126, label %127, label %128

127:                                              ; preds = %123
  br label %136

128:                                              ; preds = %123
  %129 = load i32, ptr %12, align 4, !tbaa !16
  %130 = icmp sgt i32 %129, 255
  br i1 %130, label %131, label %132

131:                                              ; preds = %128
  br label %134

132:                                              ; preds = %128
  %133 = load i32, ptr %12, align 4, !tbaa !16
  br label %134

134:                                              ; preds = %132, %131
  %135 = phi i32 [ 255, %131 ], [ %133, %132 ]
  br label %136

136:                                              ; preds = %134, %127
  %137 = phi i32 [ 0, %127 ], [ %135, %134 ]
  store i32 %137, ptr %12, align 4, !tbaa !16
  %138 = load i32, ptr %13, align 4, !tbaa !16
  %139 = icmp slt i32 %138, 0
  br i1 %139, label %140, label %141

140:                                              ; preds = %136
  br label %149

141:                                              ; preds = %136
  %142 = load i32, ptr %13, align 4, !tbaa !16
  %143 = icmp sgt i32 %142, 255
  br i1 %143, label %144, label %145

144:                                              ; preds = %141
  br label %147

145:                                              ; preds = %141
  %146 = load i32, ptr %13, align 4, !tbaa !16
  br label %147

147:                                              ; preds = %145, %144
  %148 = phi i32 [ 255, %144 ], [ %146, %145 ]
  br label %149

149:                                              ; preds = %147, %140
  %150 = phi i32 [ 0, %140 ], [ %148, %147 ]
  store i32 %150, ptr %13, align 4, !tbaa !16
  %151 = load i32, ptr %11, align 4, !tbaa !16
  %152 = trunc i32 %151 to i8
  %153 = getelementptr inbounds %class.R2Image, ptr %14, i32 0, i32 4
  %154 = load ptr, ptr %153, align 8, !tbaa !15
  %155 = load i32, ptr %10, align 4, !tbaa !16
  %156 = mul nsw i32 %155, 3
  %157 = add nsw i32 %156, 0
  %158 = sext i32 %157 to i64
  %159 = getelementptr inbounds i8, ptr %154, i64 %158
  store i8 %152, ptr %159, align 1, !tbaa !17
  %160 = load i32, ptr %12, align 4, !tbaa !16
  %161 = trunc i32 %160 to i8
  %162 = getelementptr inbounds %class.R2Image, ptr %14, i32 0, i32 4
  %163 = load ptr, ptr %162, align 8, !tbaa !15
  %164 = load i32, ptr %10, align 4, !tbaa !16
  %165 = mul nsw i32 %164, 3
  %166 = add nsw i32 %165, 1
  %167 = sext i32 %166 to i64
  %168 = getelementptr inbounds i8, ptr %163, i64 %167
  store i8 %161, ptr %168, align 1, !tbaa !17
  %169 = load i32, ptr %13, align 4, !tbaa !16
  %170 = trunc i32 %169 to i8
  %171 = getelementptr inbounds %class.R2Image, ptr %14, i32 0, i32 4
  %172 = load ptr, ptr %171, align 8, !tbaa !15
  %173 = load i32, ptr %10, align 4, !tbaa !16
  %174 = mul nsw i32 %173, 3
  %175 = add nsw i32 %174, 2
  %176 = sext i32 %175 to i64
  %177 = getelementptr inbounds i8, ptr %172, i64 %176
  store i8 %170, ptr %177, align 1, !tbaa !17
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #6
  br label %178

178:                                              ; preds = %149
  %179 = load i32, ptr %10, align 4, !tbaa !16
  %180 = add nsw i32 %179, 1
  store i32 %180, ptr %10, align 4, !tbaa !16
  br label %87, !llvm.loop !18

181:                                              ; preds = %95
  br label %182

182:                                              ; preds = %181, %69
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #6
  ret void
}

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = { 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 = { nounwind }
attributes #7 = { 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, !11, i64 0}
!10 = !{!"_ZTS7R2Image", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !6, i64 16}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !11, i64 4}
!13 = !{!10, !11, i64 8}
!14 = !{!10, !11, i64 12}
!15 = !{!10, !6, i64 16}
!16 = !{!11, !11, i64 0}
!17 = !{!7, !7, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"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"

@.str = external hidden unnamed_addr constant [41 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [89 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [41 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [41 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [40 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [40 x i8], align 1

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

declare void @_Z7RNAbortPKcz(ptr noundef, ...) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN7R2ImageC2ERK6R2GridS2_S2_(ptr nocapture noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull align 8 dereferenceable(208) %1, ptr noundef nonnull align 8 dereferenceable(208) %2, ptr noundef nonnull align 8 dereferenceable(208) %3) unnamed_addr #2 align 2 {
  %5 = tail call noundef i32 @_ZNK6R2Grid11XResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %1)
  store i32 %5, ptr %0, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %0, i64 4
  %7 = tail call noundef i32 @_ZNK6R2Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %1)
  store i32 %7, ptr %6, align 4, !tbaa !11
  %8 = getelementptr inbounds i8, ptr %0, i64 8
  store i32 3, ptr %8, align 8, !tbaa !12
  %9 = getelementptr inbounds i8, ptr %0, i64 12
  store i32 0, ptr %9, align 4, !tbaa !13
  %10 = getelementptr inbounds i8, ptr %0, i64 16
  store ptr null, ptr %10, align 8, !tbaa !14
  %11 = tail call noundef i32 @_ZNK6R2Grid11XResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %1)
  %12 = tail call noundef i32 @_ZNK6R2Grid11XResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %2)
  %.not = icmp eq i32 %11, %12
  br i1 %.not, label %13, label %14

13:                                               ; preds = %4
  tail call void (ptr, ...) @_Z7RNAbortPKcz(ptr noundef nonnull @.str, ptr noundef nonnull @.str.3, i32 noundef 91, ptr noundef nonnull @.str.2)
  br label %14

14:                                               ; preds = %13, %4
  %15 = tail call noundef i32 @_ZNK6R2Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %1)
  %16 = tail call noundef i32 @_ZNK6R2Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %2)
  %.not36 = icmp eq i32 %15, %16
  br i1 %.not36, label %17, label %18

17:                                               ; preds = %14
  tail call void (ptr, ...) @_Z7RNAbortPKcz(ptr noundef nonnull @.str, ptr noundef nonnull @.str.4, i32 noundef 92, ptr noundef nonnull @.str.2)
  br label %18

18:                                               ; preds = %17, %14
  %19 = tail call noundef i32 @_ZNK6R2Grid11XResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %1)
  %20 = tail call noundef i32 @_ZNK6R2Grid11XResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %3)
  %.not37 = icmp eq i32 %19, %20
  br i1 %.not37, label %21, label %22

21:                                               ; preds = %18
  tail call void (ptr, ...) @_Z7RNAbortPKcz(ptr noundef nonnull @.str, ptr noundef nonnull @.str.5, i32 noundef 93, ptr noundef nonnull @.str.2)
  br label %22

22:                                               ; preds = %21, %18
  %23 = tail call noundef i32 @_ZNK6R2Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %1)
  %24 = tail call noundef i32 @_ZNK6R2Grid11YResolutionEv(ptr noundef nonnull align 8 dereferenceable(208) %3)
  %.not38 = icmp eq i32 %23, %24
  br i1 %.not38, label %25, label %26

25:                                               ; preds = %22
  tail call void (ptr, ...) @_Z7RNAbortPKcz(ptr noundef nonnull @.str, ptr noundef nonnull @.str.6, i32 noundef 94, ptr noundef nonnull @.str.2)
  br label %26

26:                                               ; preds = %25, %22
  %27 = load i32, ptr %8, align 8, !tbaa !12
  %28 = load i32, ptr %0, align 8, !tbaa !5
  %29 = mul nsw i32 %28, %27
  %30 = and i32 %29, 3
  %.not39 = icmp eq i32 %30, 0
  br i1 %.not39, label %35, label %31

31:                                               ; preds = %26
  %32 = sdiv i32 %29, 4
  %33 = shl nsw i32 %32, 2
  %34 = add i32 %33, 4
  br label %35

35:                                               ; preds = %31, %26
  %storemerge = phi i32 [ %34, %31 ], [ %29, %26 ]
  store i32 %storemerge, ptr %9, align 4, !tbaa !13
  %36 = load i32, ptr %6, align 4, !tbaa !11
  %37 = mul nsw i32 %36, %storemerge
  %38 = icmp sgt i32 %37, 0
  br i1 %38, label %39, label %.loopexit

39:                                               ; preds = %35
  %40 = zext nneg i32 %37 to i64
  %41 = tail call noalias noundef nonnull ptr @_Znam(i64 noundef %40) #6
  store ptr %41, ptr %10, align 8, !tbaa !14
  %42 = mul nsw i32 %36, %28
  %43 = icmp sgt i32 %42, 0
  br i1 %43, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %39, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %39 ]
  %44 = trunc nuw nsw i64 %indvars.iv to i32
  %45 = tail call noundef double @_ZNK6R2Grid9GridValueEi(ptr noundef nonnull align 8 dereferenceable(208) %1, i32 noundef %44)
  %46 = fmul double %45, 2.550000e+02
  %47 = fptosi double %46 to i32
  %48 = tail call noundef double @_ZNK6R2Grid9GridValueEi(ptr noundef nonnull align 8 dereferenceable(208) %2, i32 noundef %44)
  %49 = fmul double %48, 2.550000e+02
  %50 = fptosi double %49 to i32
  %51 = tail call noundef double @_ZNK6R2Grid9GridValueEi(ptr noundef nonnull align 8 dereferenceable(208) %3, i32 noundef %44)
  %52 = fmul double %51, 2.550000e+02
  %53 = fptosi double %52 to i32
  %54 = tail call i32 @llvm.smin.i32(i32 %47, i32 255)
  %55 = tail call i32 @llvm.smax.i32(i32 %54, i32 0)
  %56 = tail call i32 @llvm.smin.i32(i32 %50, i32 255)
  %57 = tail call i32 @llvm.smax.i32(i32 %56, i32 0)
  %58 = tail call i32 @llvm.smin.i32(i32 %53, i32 255)
  %59 = tail call i32 @llvm.smax.i32(i32 %58, i32 0)
  %60 = trunc nuw i32 %55 to i8
  %61 = load ptr, ptr %10, align 8, !tbaa !14
  %62 = mul nuw nsw i64 %indvars.iv, 3
  %63 = getelementptr inbounds i8, ptr %61, i64 %62
  store i8 %60, ptr %63, align 1, !tbaa !15
  %64 = trunc nuw i32 %57 to i8
  %65 = load ptr, ptr %10, align 8, !tbaa !14
  %66 = getelementptr inbounds i8, ptr %65, i64 %62
  %67 = getelementptr inbounds i8, ptr %66, i64 1
  store i8 %64, ptr %67, align 1, !tbaa !15
  %68 = trunc nuw i32 %59 to i8
  %69 = load ptr, ptr %10, align 8, !tbaa !14
  %70 = getelementptr inbounds i8, ptr %69, i64 %62
  %71 = getelementptr inbounds i8, ptr %70, i64 2
  store i8 %68, ptr %71, align 1, !tbaa !15
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %72 = load i32, ptr %0, align 8, !tbaa !5
  %73 = load i32, ptr %6, align 4, !tbaa !11
  %74 = mul nsw i32 %73, %72
  %75 = sext i32 %74 to i64
  %76 = icmp slt i64 %indvars.iv.next, %75
  br i1 %76, label %.lr.ph, label %.loopexit, !llvm.loop !16

.loopexit:                                        ; preds = %.lr.ph, %39, %35
  ret void
}

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

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

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

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

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

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


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