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

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

@.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
@R2identity_affine = external global %class.R2Affine, align 8

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

declare i32 @__gxx_personality_v0(...)

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

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

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

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(84) ptr @_ZN8R2AffineaSERKS_(ptr noundef nonnull align 8 dereferenceable(84), ptr noundef nonnull align 8 dereferenceable(84)) #4 align 2

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

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

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

16:                                               ; preds = %3
  %17 = getelementptr inbounds %class.R2Grid, ptr %13, i32 0, i32 3
  store ptr null, ptr %17, align 8, !tbaa !11
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = invoke noundef i32 @_ZNK7R2Image5WidthEv(ptr noundef nonnull align 8 dereferenceable(24) %18)
          to label %20 unwind label %48

20:                                               ; preds = %16
  %21 = getelementptr inbounds %class.R2Grid, ptr %13, i32 0, i32 4
  %22 = getelementptr inbounds [2 x i32], ptr %21, i64 0, i64 0
  store i32 %19, ptr %22, align 8, !tbaa !9
  %23 = load ptr, ptr %5, align 8, !tbaa !5
  %24 = invoke noundef i32 @_ZNK7R2Image6HeightEv(ptr noundef nonnull align 8 dereferenceable(24) %23)
          to label %25 unwind label %48

25:                                               ; preds = %20
  %26 = getelementptr inbounds %class.R2Grid, ptr %13, i32 0, i32 4
  %27 = getelementptr inbounds [2 x i32], ptr %26, i64 0, i64 1
  store i32 %24, ptr %27, align 4, !tbaa !9
  %28 = getelementptr inbounds %class.R2Grid, ptr %13, i32 0, i32 4
  %29 = getelementptr inbounds [2 x i32], ptr %28, i64 0, i64 0
  %30 = load i32, ptr %29, align 8, !tbaa !9
  %31 = getelementptr inbounds %class.R2Grid, ptr %13, i32 0, i32 5
  store i32 %30, ptr %31, align 8, !tbaa !17
  %32 = getelementptr inbounds %class.R2Grid, ptr %13, i32 0, i32 5
  %33 = load i32, ptr %32, align 8, !tbaa !17
  %34 = getelementptr inbounds %class.R2Grid, ptr %13, 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 = mul nsw i32 %33, %36
  %38 = getelementptr inbounds %class.R2Grid, ptr %13, i32 0, i32 6
  store i32 %37, ptr %38, align 4, !tbaa !18
  %39 = getelementptr inbounds %class.R2Grid, ptr %13, i32 0, i32 6
  %40 = load i32, ptr %39, align 4, !tbaa !18
  %41 = icmp sle i32 %40, 0
  br i1 %41, label %42, label %52

42:                                               ; preds = %25
  %43 = getelementptr inbounds %class.R2Grid, ptr %13, i32 0, i32 3
  store ptr null, ptr %43, align 8, !tbaa !11
  br label %63

44:                                               ; preds = %3
  %45 = landingpad { ptr, i32 }
          cleanup
  %46 = extractvalue { ptr, i32 } %45, 0
  store ptr %46, ptr %7, align 8
  %47 = extractvalue { ptr, i32 } %45, 1
  store i32 %47, ptr %8, align 4
  br label %119

48:                                               ; preds = %113, %110, %71, %52, %20, %16
  %49 = landingpad { ptr, i32 }
          cleanup
  %50 = extractvalue { ptr, i32 } %49, 0
  store ptr %50, ptr %7, align 8
  %51 = extractvalue { ptr, i32 } %49, 1
  store i32 %51, ptr %8, align 4
  br label %118

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

61:                                               ; preds = %52
  %62 = getelementptr inbounds %class.R2Grid, ptr %13, i32 0, i32 3
  store ptr %60, ptr %62, align 8, !tbaa !11
  br label %63

63:                                               ; preds = %61, %42
  %64 = getelementptr inbounds %class.R2Grid, ptr %13, i32 0, i32 6
  %65 = load i32, ptr %64, align 4, !tbaa !18
  %66 = icmp ne i32 %65, 0
  br i1 %66, label %67, label %73

67:                                               ; preds = %63
  %68 = getelementptr inbounds %class.R2Grid, ptr %13, i32 0, i32 3
  %69 = load ptr, ptr %68, align 8, !tbaa !11
  %70 = icmp ne ptr %69, null
  br i1 %70, label %73, label %71

71:                                               ; preds = %67
  invoke void (ptr, ...) @_Z7RNAbortPKcz(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 194, ptr noundef @.str.2)
          to label %72 unwind label %48

72:                                               ; preds = %71
  br label %73

73:                                               ; preds = %72, %67, %63
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #9
  store i32 0, ptr %9, align 4, !tbaa !9
  br label %74

74:                                               ; preds = %107, %73
  %75 = load i32, ptr %9, align 4, !tbaa !9
  %76 = getelementptr inbounds %class.R2Grid, ptr %13, i32 0, i32 4
  %77 = getelementptr inbounds [2 x i32], ptr %76, i64 0, i64 1
  %78 = load i32, ptr %77, align 4, !tbaa !9
  %79 = icmp slt i32 %75, %78
  br i1 %79, label %81, label %80

80:                                               ; preds = %74
  store i32 2, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #9
  br label %110

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

82:                                               ; preds = %99, %81
  %83 = load i32, ptr %11, align 4, !tbaa !9
  %84 = getelementptr inbounds %class.R2Grid, ptr %13, i32 0, i32 4
  %85 = getelementptr inbounds [2 x i32], ptr %84, i64 0, i64 0
  %86 = load i32, ptr %85, align 8, !tbaa !9
  %87 = icmp slt i32 %83, %86
  br i1 %87, label %89, label %88

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

89:                                               ; preds = %82
  call void @llvm.lifetime.start.p0(i64 24, ptr %12) #9
  %90 = load ptr, ptr %5, align 8, !tbaa !5
  %91 = load i32, ptr %11, align 4, !tbaa !9
  %92 = load i32, ptr %9, align 4, !tbaa !9
  invoke void @_ZNK7R2Image8PixelRGBEii(ptr dead_on_unwind writable sret(%class.RNRgb) align 8 %12, ptr noundef nonnull align 8 dereferenceable(24) %90, i32 noundef %91, i32 noundef %92)
          to label %93 unwind label %102

93:                                               ; preds = %89
  %94 = load i32, ptr %11, align 4, !tbaa !9
  %95 = load i32, ptr %9, align 4, !tbaa !9
  %96 = invoke noundef double @_ZNK5RNRgb9LuminanceEv(ptr noundef nonnull align 8 dereferenceable(24) %12)
          to label %97 unwind label %102

97:                                               ; preds = %93
  invoke void @_ZN6R2Grid12SetGridValueEiid(ptr noundef nonnull align 8 dereferenceable(208) %13, i32 noundef %94, i32 noundef %95, double noundef %96)
          to label %98 unwind label %102

98:                                               ; preds = %97
  call void @llvm.lifetime.end.p0(i64 24, ptr %12) #9
  br label %99

99:                                               ; preds = %98
  %100 = load i32, ptr %11, align 4, !tbaa !9
  %101 = add nsw i32 %100, 1
  store i32 %101, ptr %11, align 4, !tbaa !9
  br label %82, !llvm.loop !19

102:                                              ; preds = %97, %93, %89
  %103 = landingpad { ptr, i32 }
          cleanup
  %104 = extractvalue { ptr, i32 } %103, 0
  store ptr %104, ptr %7, align 8
  %105 = extractvalue { ptr, i32 } %103, 1
  store i32 %105, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 24, ptr %12) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #9
  br label %118

106:                                              ; preds = %88
  br label %107

107:                                              ; preds = %106
  %108 = load i32, ptr %9, align 4, !tbaa !9
  %109 = add nsw i32 %108, 1
  store i32 %109, ptr %9, align 4, !tbaa !9
  br label %74, !llvm.loop !21

110:                                              ; preds = %80
  %111 = getelementptr inbounds %class.R2Grid, ptr %13, i32 0, i32 0
  %112 = invoke noundef nonnull align 8 dereferenceable(84) ptr @_ZN8R2AffineaSERKS_(ptr noundef nonnull align 8 dereferenceable(84) %111, ptr noundef nonnull align 8 dereferenceable(84) @R2identity_affine)
          to label %113 unwind label %48

113:                                              ; preds = %110
  %114 = getelementptr inbounds %class.R2Grid, ptr %13, i32 0, i32 1
  %115 = invoke noundef nonnull align 8 dereferenceable(84) ptr @_ZN8R2AffineaSERKS_(ptr noundef nonnull align 8 dereferenceable(84) %114, ptr noundef nonnull align 8 dereferenceable(84) @R2identity_affine)
          to label %116 unwind label %48

116:                                              ; preds = %113
  %117 = getelementptr inbounds %class.R2Grid, ptr %13, i32 0, i32 2
  store double 1.000000e+00, ptr %117, align 8, !tbaa !22
  ret void

118:                                              ; preds = %102, %48
  call void @_ZN16R2TransformationD2Ev(ptr noundef nonnull align 8 dereferenceable(84) %15) #9
  br label %119

119:                                              ; preds = %118, %44
  call void @_ZN16R2TransformationD2Ev(ptr noundef nonnull align 8 dereferenceable(84) %14) #9
  br label %120

120:                                              ; preds = %119
  %121 = load ptr, ptr %7, align 8
  %122 = load i32, ptr %8, align 4
  %123 = insertvalue { ptr, i32 } poison, ptr %121, 0
  %124 = insertvalue { ptr, i32 } %123, i32 %122, 1
  resume { ptr, i32 } %124
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK7R2Image5WidthEv(ptr noundef nonnull align 8 dereferenceable(24)) #7 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK7R2Image6HeightEv(ptr noundef nonnull align 8 dereferenceable(24)) #7 align 2

declare void @_ZNK7R2Image8PixelRGBEii(ptr dead_on_unwind writable sret(%class.RNRgb) align 8, ptr noundef nonnull align 8 dereferenceable(24), i32 noundef, i32 noundef) #0

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZNK5RNRgb9LuminanceEv(ptr noundef nonnull align 8 dereferenceable(24)) #7 align 2

attributes #0 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { nobuiltin allocsize(0) "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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 = { 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 = { 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 #8 = { builtin allocsize(0) }
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, !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 = !{!12, !10, i64 200}
!18 = !{!12, !10, i64 204}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = distinct !{!21, !20}
!22 = !{!12, !16, i64 176}


; 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.R2Affine = type <{ %class.R2Transformation, %class.R3Matrix, i32, [4 x i8] }>
%class.R2Transformation = type { ptr }
%class.R3Matrix = type { [3 x [3 x double]] }
%class.RNRgb = type { [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
@R2identity_affine = external global %class.R2Affine, align 8

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

declare i32 @__gxx_personality_v0(...)

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

declare void @_Z7RNAbortPKcz(ptr 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) #2

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(84) ptr @_ZN8R2AffineaSERKS_(ptr noundef nonnull align 8 dereferenceable(84), ptr noundef nonnull align 8 dereferenceable(84)) local_unnamed_addr #3 align 2

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

; 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: mustprogress uwtable
define dso_local void @_ZN6R2GridC2ERK7R2Imagei(ptr noundef nonnull align 8 dereferenceable(208) %0, ptr noundef nonnull align 8 dereferenceable(24) %1, i32 noundef %2) unnamed_addr #5 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca %class.RNRgb, align 8
  tail call void @_ZN8R2AffineC1Ev(ptr noundef nonnull align 8 dereferenceable(84) %0)
  %5 = getelementptr inbounds i8, ptr %0, i64 88
  invoke void @_ZN8R2AffineC1Ev(ptr noundef nonnull align 8 dereferenceable(84) %5)
          to label %6 unwind label %17

6:                                                ; preds = %3
  %7 = getelementptr inbounds i8, ptr %0, i64 184
  store ptr null, ptr %7, align 8, !tbaa !5
  %8 = tail call noundef i32 @_ZNK7R2Image5WidthEv(ptr noundef nonnull align 8 dereferenceable(24) %1)
  %9 = getelementptr inbounds i8, ptr %0, i64 192
  store i32 %8, ptr %9, align 8, !tbaa !15
  %10 = tail call noundef i32 @_ZNK7R2Image6HeightEv(ptr noundef nonnull align 8 dereferenceable(24) %1)
  %11 = getelementptr inbounds i8, ptr %0, i64 196
  store i32 %10, ptr %11, align 4, !tbaa !15
  %12 = load i32, ptr %9, align 8, !tbaa !15
  %13 = getelementptr inbounds i8, ptr %0, i64 200
  store i32 %12, ptr %13, align 8, !tbaa !16
  %14 = mul nsw i32 %12, %10
  %15 = getelementptr inbounds i8, ptr %0, i64 204
  store i32 %14, ptr %15, align 4, !tbaa !17
  %16 = icmp slt i32 %14, 1
  br i1 %16, label %25, label %21

17:                                               ; preds = %3
  %18 = landingpad { ptr, i32 }
          cleanup
  br label %53

19:                                               ; preds = %48, %._crit_edge27, %26, %21
  %20 = landingpad { ptr, i32 }
          cleanup
  br label %52

21:                                               ; preds = %6
  %22 = zext nneg i32 %14 to i64
  %23 = shl nuw nsw i64 %22, 3
  %24 = invoke noalias noundef nonnull ptr @_Znam(i64 noundef %23) #7
          to label %.thread unwind label %19

.thread:                                          ; preds = %21
  store ptr %24, ptr %7, align 8, !tbaa !5
  br label %27

25:                                               ; preds = %6
  store ptr null, ptr %7, align 8, !tbaa !5
  %.not.not = icmp eq i32 %14, 0
  br i1 %.not.not, label %27, label %26

26:                                               ; preds = %25
  invoke void (ptr, ...) @_Z7RNAbortPKcz(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 194, ptr noundef nonnull @.str.2)
          to label %._crit_edge29 unwind label %19

._crit_edge29:                                    ; preds = %26
  %.pre = load i32, ptr %11, align 4, !tbaa !15
  br label %27

27:                                               ; preds = %._crit_edge29, %.thread, %25
  %28 = phi i32 [ %.pre, %._crit_edge29 ], [ %10, %.thread ], [ %10, %25 ]
  %29 = icmp sgt i32 %28, 0
  %30 = load i32, ptr %9, align 8
  %31 = icmp sgt i32 %30, 0
  %or.cond = select i1 %29, i1 %31, i1 false
  br i1 %or.cond, label %.preheader, label %._crit_edge27

.preheader:                                       ; preds = %27, %._crit_edge
  %32 = phi i32 [ %36, %._crit_edge ], [ %28, %27 ]
  %33 = phi i32 [ %37, %._crit_edge ], [ %30, %27 ]
  %.01326 = phi i32 [ %38, %._crit_edge ], [ 0, %27 ]
  %34 = icmp sgt i32 %33, 0
  br i1 %34, label %.lr.ph, label %._crit_edge

._crit_edge27:                                    ; preds = %._crit_edge, %27
  %35 = invoke noundef nonnull align 8 dereferenceable(84) ptr @_ZN8R2AffineaSERKS_(ptr noundef nonnull align 8 dereferenceable(84) %0, ptr noundef nonnull align 8 dereferenceable(84) @R2identity_affine)
          to label %48 unwind label %19

._crit_edge.loopexit:                             ; preds = %42
  %.pre30 = load i32, ptr %11, align 4, !tbaa !15
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %.preheader
  %36 = phi i32 [ %.pre30, %._crit_edge.loopexit ], [ %32, %.preheader ]
  %37 = phi i32 [ %44, %._crit_edge.loopexit ], [ %33, %.preheader ]
  %38 = add nuw nsw i32 %.01326, 1
  %39 = icmp slt i32 %38, %36
  br i1 %39, label %.preheader, label %._crit_edge27, !llvm.loop !18

.lr.ph:                                           ; preds = %.preheader, %42
  %.025 = phi i32 [ %43, %42 ], [ 0, %.preheader ]
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %4) #8
  invoke void @_ZNK7R2Image8PixelRGBEii(ptr dead_on_unwind nonnull writable sret(%class.RNRgb) align 8 %4, ptr noundef nonnull align 8 dereferenceable(24) %1, i32 noundef %.025, i32 noundef %.01326)
          to label %40 unwind label %46

40:                                               ; preds = %.lr.ph
  %41 = call noundef double @_ZNK5RNRgb9LuminanceEv(ptr noundef nonnull align 8 dereferenceable(24) %4)
  invoke void @_ZN6R2Grid12SetGridValueEiid(ptr noundef nonnull align 8 dereferenceable(208) %0, i32 noundef %.025, i32 noundef %.01326, double noundef %41)
          to label %42 unwind label %46

42:                                               ; preds = %40
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %4) #8
  %43 = add nuw nsw i32 %.025, 1
  %44 = load i32, ptr %9, align 8, !tbaa !15
  %45 = icmp slt i32 %43, %44
  br i1 %45, label %.lr.ph, label %._crit_edge.loopexit, !llvm.loop !21

46:                                               ; preds = %40, %.lr.ph
  %47 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %4) #8
  br label %52

48:                                               ; preds = %._crit_edge27
  %49 = invoke noundef nonnull align 8 dereferenceable(84) ptr @_ZN8R2AffineaSERKS_(ptr noundef nonnull align 8 dereferenceable(84) %5, ptr noundef nonnull align 8 dereferenceable(84) @R2identity_affine)
          to label %50 unwind label %19

50:                                               ; preds = %48
  %51 = getelementptr inbounds i8, ptr %0, i64 176
  store double 1.000000e+00, ptr %51, align 8, !tbaa !22
  ret void

52:                                               ; preds = %46, %19
  %.pn = phi { ptr, i32 } [ %47, %46 ], [ %20, %19 ]
  call void @_ZN16R2TransformationD2Ev(ptr noundef nonnull align 8 dereferenceable(84) %5) #8
  br label %53

53:                                               ; preds = %52, %17
  %.pn.pn = phi { ptr, i32 } [ %.pn, %52 ], [ %18, %17 ]
  call void @_ZN16R2TransformationD2Ev(ptr noundef nonnull align 8 dereferenceable(84) %0) #8
  resume { ptr, i32 } %.pn.pn
}

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

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

declare void @_ZNK7R2Image8PixelRGBEii(ptr dead_on_unwind writable sret(%class.RNRgb) align 8, ptr noundef nonnull align 8 dereferenceable(24), i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZNK5RNRgb9LuminanceEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #6 align 2

attributes #0 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nobuiltin allocsize(0) "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 = { nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #6 = { inlinehint mustprogress 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 #7 = { builtin allocsize(0) }
attributes #8 = { 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 = !{!6, !12, i64 200}
!17 = !{!6, !12, i64 204}
!18 = distinct !{!18, !19, !20}
!19 = !{!"llvm.loop.mustprogress"}
!20 = !{!"llvm.loop.unswitch.partial.disable"}
!21 = distinct !{!21, !19}
!22 = !{!6, !13, i64 176}


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