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

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

@R2identity_affine = external global %class.R2Affine, align 8
@stderr = external global ptr, align 8
@.str.79 = external hidden unnamed_addr constant [33 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

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

; Function Attrs: 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)) #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) #3 align 2

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK7R2Image6HeightEv(ptr noundef nonnull align 8 dereferenceable(24)) #4 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) #5

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

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

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #7

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

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) #6

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN6R2Grid9ReadImageEPKc(ptr noundef nonnull align 8 dereferenceable(208) %0, ptr noundef %1) #8 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %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
  %13 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #9
  %14 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 24) #10
  invoke void @_ZN7R2ImageC1Ev(ptr noundef nonnull align 8 dereferenceable(24) %14)
          to label %15 unwind label %22

15:                                               ; preds = %2
  store ptr %14, ptr %6, align 8, !tbaa !5
  %16 = load ptr, ptr %6, align 8, !tbaa !5
  %17 = icmp ne ptr %16, null
  br i1 %17, label %26, label %18

18:                                               ; preds = %15
  %19 = load ptr, ptr @stderr, align 8, !tbaa !5
  %20 = load ptr, ptr %5, align 8, !tbaa !5
  %21 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %19, ptr noundef @.str.79, ptr noundef %20) #9
  store i32 0, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %110

22:                                               ; preds = %2
  %23 = landingpad { ptr, i32 }
          cleanup
  %24 = extractvalue { ptr, i32 } %23, 0
  store ptr %24, ptr %7, align 8
  %25 = extractvalue { ptr, i32 } %23, 1
  store i32 %25, ptr %8, align 4
  call void @_ZdlPvm(ptr noundef %14, i64 noundef 24) #11
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #9
  br label %112

26:                                               ; preds = %15
  %27 = load ptr, ptr %6, align 8, !tbaa !5
  %28 = load ptr, ptr %5, align 8, !tbaa !5
  %29 = call noundef i32 @_ZN7R2Image4ReadEPKc(ptr noundef nonnull align 8 dereferenceable(24) %27, ptr noundef %28)
  %30 = icmp ne i32 %29, 0
  br i1 %30, label %36, label %31

31:                                               ; preds = %26
  %32 = load ptr, ptr %6, align 8, !tbaa !5
  %33 = icmp eq ptr %32, null
  br i1 %33, label %35, label %34

34:                                               ; preds = %31
  call void @_ZN7R2ImageD1Ev(ptr noundef nonnull align 8 dereferenceable(24) %32) #9
  call void @_ZdlPvm(ptr noundef %32, i64 noundef 24) #11
  br label %35

35:                                               ; preds = %34, %31
  store i32 0, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %110

36:                                               ; preds = %26
  %37 = load ptr, ptr %6, align 8, !tbaa !5
  %38 = call noundef i32 @_ZNK7R2Image5WidthEv(ptr noundef nonnull align 8 dereferenceable(24) %37)
  %39 = getelementptr inbounds %class.R2Grid, ptr %13, i32 0, i32 4
  %40 = getelementptr inbounds [2 x i32], ptr %39, i64 0, i64 0
  store i32 %38, ptr %40, align 8, !tbaa !9
  %41 = load ptr, ptr %6, align 8, !tbaa !5
  %42 = call noundef i32 @_ZNK7R2Image6HeightEv(ptr noundef nonnull align 8 dereferenceable(24) %41)
  %43 = getelementptr inbounds %class.R2Grid, ptr %13, i32 0, i32 4
  %44 = getelementptr inbounds [2 x i32], ptr %43, i64 0, i64 1
  store i32 %42, ptr %44, align 4, !tbaa !9
  %45 = load ptr, ptr %6, align 8, !tbaa !5
  %46 = call noundef i32 @_ZNK7R2Image5WidthEv(ptr noundef nonnull align 8 dereferenceable(24) %45)
  %47 = getelementptr inbounds %class.R2Grid, ptr %13, i32 0, i32 5
  store i32 %46, ptr %47, align 8, !tbaa !11
  %48 = load ptr, ptr %6, align 8, !tbaa !5
  %49 = call noundef i32 @_ZNK7R2Image5WidthEv(ptr noundef nonnull align 8 dereferenceable(24) %48)
  %50 = load ptr, ptr %6, align 8, !tbaa !5
  %51 = call noundef i32 @_ZNK7R2Image6HeightEv(ptr noundef nonnull align 8 dereferenceable(24) %50)
  %52 = mul nsw i32 %49, %51
  %53 = getelementptr inbounds %class.R2Grid, ptr %13, i32 0, i32 6
  store i32 %52, ptr %53, align 4, !tbaa !17
  %54 = getelementptr inbounds %class.R2Grid, ptr %13, i32 0, i32 2
  store double 1.000000e+00, ptr %54, align 8, !tbaa !18
  %55 = getelementptr inbounds %class.R2Grid, ptr %13, i32 0, i32 1
  %56 = call noundef nonnull align 8 dereferenceable(84) ptr @_ZN8R2AffineaSERKS_(ptr noundef nonnull align 8 dereferenceable(84) %55, ptr noundef nonnull align 8 dereferenceable(84) @R2identity_affine)
  %57 = getelementptr inbounds %class.R2Grid, ptr %13, i32 0, i32 0
  %58 = call noundef nonnull align 8 dereferenceable(84) ptr @_ZN8R2AffineaSERKS_(ptr noundef nonnull align 8 dereferenceable(84) %57, ptr noundef nonnull align 8 dereferenceable(84) @R2identity_affine)
  %59 = getelementptr inbounds %class.R2Grid, ptr %13, i32 0, i32 3
  %60 = load ptr, ptr %59, align 8, !tbaa !19
  %61 = icmp ne ptr %60, null
  br i1 %61, label %62, label %68

62:                                               ; preds = %36
  %63 = getelementptr inbounds %class.R2Grid, ptr %13, i32 0, i32 3
  %64 = load ptr, ptr %63, align 8, !tbaa !19
  %65 = icmp eq ptr %64, null
  br i1 %65, label %67, label %66

66:                                               ; preds = %62
  call void @_ZdaPv(ptr noundef %64) #11
  br label %67

67:                                               ; preds = %66, %62
  br label %68

68:                                               ; preds = %67, %36
  %69 = getelementptr inbounds %class.R2Grid, ptr %13, i32 0, i32 6
  %70 = load i32, ptr %69, align 4, !tbaa !17
  %71 = sext i32 %70 to i64
  %72 = call { i64, i1 } @llvm.umul.with.overflow.i64(i64 %71, i64 8)
  %73 = extractvalue { i64, i1 } %72, 1
  %74 = extractvalue { i64, i1 } %72, 0
  %75 = select i1 %73, i64 -1, i64 %74
  %76 = call noalias noundef nonnull ptr @_Znam(i64 noundef %75) #10
  %77 = getelementptr inbounds %class.R2Grid, ptr %13, i32 0, i32 3
  store ptr %76, ptr %77, align 8, !tbaa !19
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #9
  store i32 0, ptr %10, align 4, !tbaa !9
  br label %78

78:                                               ; preds = %102, %68
  %79 = load i32, ptr %10, align 4, !tbaa !9
  %80 = load ptr, ptr %6, align 8, !tbaa !5
  %81 = call noundef i32 @_ZNK7R2Image6HeightEv(ptr noundef nonnull align 8 dereferenceable(24) %80)
  %82 = icmp slt i32 %79, %81
  br i1 %82, label %84, label %83

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

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

85:                                               ; preds = %98, %84
  %86 = load i32, ptr %11, align 4, !tbaa !9
  %87 = load ptr, ptr %6, align 8, !tbaa !5
  %88 = call noundef i32 @_ZNK7R2Image5WidthEv(ptr noundef nonnull align 8 dereferenceable(24) %87)
  %89 = icmp slt i32 %86, %88
  br i1 %89, label %91, label %90

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

91:                                               ; preds = %85
  %92 = load i32, ptr %11, align 4, !tbaa !9
  %93 = load i32, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 24, ptr %12) #9
  %94 = load ptr, ptr %6, align 8, !tbaa !5
  %95 = load i32, ptr %11, align 4, !tbaa !9
  %96 = load i32, ptr %10, align 4, !tbaa !9
  call void @_ZNK7R2Image8PixelRGBEii(ptr dead_on_unwind writable sret(%class.RNRgb) align 8 %12, ptr noundef nonnull align 8 dereferenceable(24) %94, i32 noundef %95, i32 noundef %96)
  %97 = call noundef double @_ZNK5RNRgb9LuminanceEv(ptr noundef nonnull align 8 dereferenceable(24) %12)
  call void @_ZN6R2Grid12SetGridValueEiid(ptr noundef nonnull align 8 dereferenceable(208) %13, i32 noundef %92, i32 noundef %93, double noundef %97)
  call void @llvm.lifetime.end.p0(i64 24, ptr %12) #9
  br label %98

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

101:                                              ; preds = %90
  br label %102

102:                                              ; preds = %101
  %103 = load i32, ptr %10, align 4, !tbaa !9
  %104 = add nsw i32 %103, 1
  store i32 %104, ptr %10, align 4, !tbaa !9
  br label %78, !llvm.loop !22

105:                                              ; preds = %83
  %106 = load ptr, ptr %6, align 8, !tbaa !5
  %107 = icmp eq ptr %106, null
  br i1 %107, label %109, label %108

108:                                              ; preds = %105
  call void @_ZN7R2ImageD1Ev(ptr noundef nonnull align 8 dereferenceable(24) %106) #9
  call void @_ZdlPvm(ptr noundef %106, i64 noundef 24) #11
  br label %109

109:                                              ; preds = %108, %105
  store i32 1, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %110

110:                                              ; preds = %109, %35, %18
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #9
  %111 = load i32, ptr %3, align 4
  ret i32 %111

112:                                              ; preds = %22
  %113 = load ptr, ptr %7, align 8
  %114 = load i32, ptr %8, align 4
  %115 = insertvalue { ptr, i32 } poison, ptr %113, 0
  %116 = insertvalue { ptr, i32 } %115, i32 %114, 1
  resume { ptr, i32 } %116
}

declare void @_ZN7R2ImageC1Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #5

declare noundef i32 @_ZN7R2Image4ReadEPKc(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef) #5

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

attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { nobuiltin allocsize(0) "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { 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 = { 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 = { "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 = { nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #8 = { 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 #9 = { nounwind }
attributes #10 = { builtin allocsize(0) }
attributes #11 = { builtin nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !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, !16, i64 176}
!19 = !{!12, !6, i64 184}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}
!22 = distinct !{!22, !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.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] }

@R2identity_affine = external global %class.R2Affine, align 8

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK7R2Image6HeightEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #3 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 #4

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

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

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

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) local_unnamed_addr #5

; Function Attrs: mustprogress uwtable
define dso_local noundef range(i32 0, 2) i32 @_ZN6R2Grid9ReadImageEPKc(ptr noundef nonnull align 8 dereferenceable(208) %0, ptr noundef %1) local_unnamed_addr #6 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca %class.RNRgb, align 8
  %4 = tail call noalias noundef nonnull dereferenceable(24) ptr @_Znwm(i64 noundef 24) #8
  invoke void @_ZN7R2ImageC1Ev(ptr noundef nonnull align 8 dereferenceable(24) %4)
          to label %7 unwind label %5

5:                                                ; preds = %2
  %6 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZdlPvm(ptr noundef nonnull %4, i64 noundef 24) #9
  resume { ptr, i32 } %6

7:                                                ; preds = %2
  %8 = tail call noundef i32 @_ZN7R2Image4ReadEPKc(ptr noundef nonnull align 8 dereferenceable(24) %4, ptr noundef %1)
  %.not = icmp eq i32 %8, 0
  br i1 %.not, label %9, label %10

9:                                                ; preds = %7
  tail call void @_ZN7R2ImageD1Ev(ptr noundef nonnull align 8 dereferenceable(24) %4) #10
  tail call void @_ZdlPvm(ptr noundef nonnull %4, i64 noundef 24) #9
  br label %46

10:                                               ; preds = %7
  %11 = tail call noundef i32 @_ZNK7R2Image5WidthEv(ptr noundef nonnull align 8 dereferenceable(24) %4)
  %12 = getelementptr inbounds i8, ptr %0, i64 192
  store i32 %11, ptr %12, align 8, !tbaa !5
  %13 = tail call noundef i32 @_ZNK7R2Image6HeightEv(ptr noundef nonnull align 8 dereferenceable(24) %4)
  %14 = getelementptr inbounds i8, ptr %0, i64 196
  store i32 %13, ptr %14, align 4, !tbaa !5
  %15 = tail call noundef i32 @_ZNK7R2Image5WidthEv(ptr noundef nonnull align 8 dereferenceable(24) %4)
  %16 = getelementptr inbounds i8, ptr %0, i64 200
  store i32 %15, ptr %16, align 8, !tbaa !9
  %17 = tail call noundef i32 @_ZNK7R2Image5WidthEv(ptr noundef nonnull align 8 dereferenceable(24) %4)
  %18 = tail call noundef i32 @_ZNK7R2Image6HeightEv(ptr noundef nonnull align 8 dereferenceable(24) %4)
  %19 = mul nsw i32 %18, %17
  %20 = getelementptr inbounds i8, ptr %0, i64 204
  store i32 %19, ptr %20, align 4, !tbaa !16
  %21 = getelementptr inbounds i8, ptr %0, i64 176
  store double 1.000000e+00, ptr %21, align 8, !tbaa !17
  %22 = getelementptr inbounds i8, ptr %0, i64 88
  %23 = tail call noundef nonnull align 8 dereferenceable(84) ptr @_ZN8R2AffineaSERKS_(ptr noundef nonnull align 8 dereferenceable(84) %22, ptr noundef nonnull align 8 dereferenceable(84) @R2identity_affine)
  %24 = tail call 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)
  %25 = getelementptr inbounds i8, ptr %0, i64 184
  %26 = load ptr, ptr %25, align 8, !tbaa !18
  %.not28 = icmp eq ptr %26, null
  br i1 %.not28, label %28, label %27

27:                                               ; preds = %10
  tail call void @_ZdaPv(ptr noundef nonnull %26) #9
  br label %28

28:                                               ; preds = %27, %10
  %29 = load i32, ptr %20, align 4, !tbaa !16
  %30 = sext i32 %29 to i64
  %31 = icmp slt i32 %29, 0
  %32 = shl nsw i64 %30, 3
  %33 = select i1 %31, i64 -1, i64 %32
  %34 = tail call noalias noundef nonnull ptr @_Znam(i64 noundef %33) #8
  store ptr %34, ptr %25, align 8, !tbaa !18
  %35 = tail call noundef i32 @_ZNK7R2Image6HeightEv(ptr noundef nonnull align 8 dereferenceable(24) %4)
  %36 = icmp sgt i32 %35, 0
  br i1 %36, label %.preheader, label %._crit_edge31

.preheader:                                       ; preds = %28, %._crit_edge
  %.02530 = phi i32 [ %39, %._crit_edge ], [ 0, %28 ]
  %37 = call noundef i32 @_ZNK7R2Image5WidthEv(ptr noundef nonnull align 8 dereferenceable(24) %4)
  %38 = icmp sgt i32 %37, 0
  br i1 %38, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %.preheader
  %39 = add nuw nsw i32 %.02530, 1
  %40 = call noundef i32 @_ZNK7R2Image6HeightEv(ptr noundef nonnull align 8 dereferenceable(24) %4)
  %41 = icmp slt i32 %39, %40
  br i1 %41, label %.preheader, label %._crit_edge31, !llvm.loop !19

.lr.ph:                                           ; preds = %.preheader, %.lr.ph
  %.029 = phi i32 [ %43, %.lr.ph ], [ 0, %.preheader ]
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %3) #10
  call void @_ZNK7R2Image8PixelRGBEii(ptr dead_on_unwind nonnull writable sret(%class.RNRgb) align 8 %3, ptr noundef nonnull align 8 dereferenceable(24) %4, i32 noundef %.029, i32 noundef %.02530)
  %42 = call noundef double @_ZNK5RNRgb9LuminanceEv(ptr noundef nonnull align 8 dereferenceable(24) %3)
  call void @_ZN6R2Grid12SetGridValueEiid(ptr noundef nonnull align 8 dereferenceable(208) %0, i32 noundef %.029, i32 noundef %.02530, double noundef %42)
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %3) #10
  %43 = add nuw nsw i32 %.029, 1
  %44 = call noundef i32 @_ZNK7R2Image5WidthEv(ptr noundef nonnull align 8 dereferenceable(24) %4)
  %45 = icmp slt i32 %43, %44
  br i1 %45, label %.lr.ph, label %._crit_edge, !llvm.loop !21

._crit_edge31:                                    ; preds = %._crit_edge, %28
  call void @_ZN7R2ImageD1Ev(ptr noundef nonnull align 8 dereferenceable(24) %4) #10
  call void @_ZdlPvm(ptr noundef nonnull %4, i64 noundef 24) #9
  br label %46

46:                                               ; preds = %._crit_edge31, %9
  %.026 = phi i32 [ 1, %._crit_edge31 ], [ 0, %9 ]
  ret i32 %.026
}

declare void @_ZN7R2ImageC1Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #4

declare noundef i32 @_ZN7R2Image4ReadEPKc(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef) local_unnamed_addr #4

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

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 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 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { nobuiltin nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #6 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #7 = { nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #8 = { builtin allocsize(0) }
attributes #9 = { builtin nounwind }
attributes #10 = { 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 = !{!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, !14, i64 176}
!18 = !{!10, !15, i64 184}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = distinct !{!21, !20}


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