; LLVM IR from niessner/Matterport :: code/gaps/pkgs/RGBD/RGBDSurface.ll (ZN11RGBDSurface18WriteColorChannelsEv)

; 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.RNRgb = type { [3 x double] }
%class.R2Image = type { i32, i32, i32, i32, ptr }
%class.RGBDSurface = type { ptr, ptr, i32, %class.RNArray, i32, i32, i32, ptr, ptr, %class.R2Box, i32, ptr, ptr, ptr }
%class.RNArray = type { %class.RNVArray }
%class.RNVArray = type { ptr, i32, i32 }
%class.R2Box = type { %class.R2Solid, %class.R2Point, %class.R2Point }
%class.R2Solid = type { %class.R2Shape }
%class.R2Shape = type { ptr }
%class.R2Point = type { [2 x double] }

@.str.6 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [10 x i8], align 1

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: mustprogress uwtable
declare dso_local void @_ZNK11RGBDSurface10TexelColorEii(ptr dead_on_unwind noalias writable sret(%class.RNRgb) align 8, ptr noundef nonnull align 8 dereferenceable(144), i32 noundef, i32 noundef) #1 align 2

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

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

declare void @_ZN7R2ImageC1Eiii(ptr noundef nonnull align 8 dereferenceable(24), i32 noundef, i32 noundef, i32 noundef) unnamed_addr #3

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK17RGBDConfiguration16TextureDirectoryEv(ptr noundef nonnull align 8 dereferenceable(128)) #2 align 2

; Function Attrs: nounwind
declare i32 @sprintf(ptr noundef, ptr noundef, ...) #4

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN11RGBDSurface18WriteColorChannelsEv(ptr noundef nonnull align 8 dereferenceable(144) %0) unnamed_addr #1 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca [4096 x i8], align 16
  %5 = alloca [4096 x i8], align 16
  %6 = alloca ptr, align 8
  %7 = alloca %class.R2Image, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca %class.RNRgb, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  %14 = load ptr, ptr %3, align 8
  %15 = call noundef i32 @_ZNK11RGBDSurface9NChannelsEv(ptr noundef nonnull align 8 dereferenceable(144) %14)
  %16 = icmp sle i32 %15, 2
  br i1 %16, label %17, label %18

17:                                               ; preds = %1
  store i32 0, ptr %2, align 4
  br label %103

18:                                               ; preds = %1
  %19 = getelementptr inbounds %class.RGBDSurface, ptr %14, i32 0, i32 7
  %20 = load ptr, ptr %19, align 8, !tbaa !9
  %21 = icmp ne ptr %20, null
  br i1 %21, label %30, label %22

22:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 4096, ptr %4) #5
  %23 = getelementptr inbounds [4096 x i8], ptr %4, i64 0, i64 0
  %24 = call noundef i32 @_ZNK11RGBDSurface18ConfigurationIndexEv(ptr noundef nonnull align 8 dereferenceable(144) %14)
  %25 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef %23, ptr noundef @.str.9, i32 noundef %24) #5
  %26 = getelementptr inbounds [4096 x i8], ptr %4, i64 0, i64 0
  %27 = load ptr, ptr %14, align 8, !tbaa !18
  %28 = getelementptr inbounds ptr, ptr %27, i64 23
  %29 = load ptr, ptr %28, align 8
  call void %29(ptr noundef nonnull align 8 dereferenceable(144) %14, ptr noundef %26)
  call void @llvm.lifetime.end.p0(i64 4096, ptr %4) #5
  br label %30

30:                                               ; preds = %22, %18
  call void @llvm.lifetime.start.p0(i64 4096, ptr %5) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  %31 = getelementptr inbounds %class.RGBDSurface, ptr %14, i32 0, i32 1
  %32 = load ptr, ptr %31, align 8, !tbaa !20
  %33 = icmp ne ptr %32, null
  br i1 %33, label %34, label %38

34:                                               ; preds = %30
  %35 = getelementptr inbounds %class.RGBDSurface, ptr %14, i32 0, i32 1
  %36 = load ptr, ptr %35, align 8, !tbaa !20
  %37 = call noundef ptr @_ZNK17RGBDConfiguration16TextureDirectoryEv(ptr noundef nonnull align 8 dereferenceable(128) %36)
  br label %39

38:                                               ; preds = %30
  br label %39

39:                                               ; preds = %38, %34
  %40 = phi ptr [ %37, %34 ], [ null, %38 ]
  store ptr %40, ptr %6, align 8, !tbaa !5
  %41 = load ptr, ptr %6, align 8, !tbaa !5
  %42 = icmp ne ptr %41, null
  br i1 %42, label %43, label %49

43:                                               ; preds = %39
  %44 = getelementptr inbounds [4096 x i8], ptr %5, i64 0, i64 0
  %45 = load ptr, ptr %6, align 8, !tbaa !5
  %46 = getelementptr inbounds %class.RGBDSurface, ptr %14, i32 0, i32 7
  %47 = load ptr, ptr %46, align 8, !tbaa !9
  %48 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef %44, ptr noundef @.str.6, ptr noundef %45, ptr noundef %47) #5
  br label %54

49:                                               ; preds = %39
  %50 = getelementptr inbounds [4096 x i8], ptr %5, i64 0, i64 0
  %51 = getelementptr inbounds %class.RGBDSurface, ptr %14, i32 0, i32 7
  %52 = load ptr, ptr %51, align 8, !tbaa !9
  %53 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef %50, ptr noundef @.str.7, ptr noundef %52) #5
  br label %54

54:                                               ; preds = %49, %43
  call void @llvm.lifetime.start.p0(i64 24, ptr %7) #5
  %55 = getelementptr inbounds %class.RGBDSurface, ptr %14, i32 0, i32 4
  %56 = load i32, ptr %55, align 8, !tbaa !21
  %57 = getelementptr inbounds %class.RGBDSurface, ptr %14, i32 0, i32 5
  %58 = load i32, ptr %57, align 4, !tbaa !22
  call void @_ZN7R2ImageC1Eiii(ptr noundef nonnull align 8 dereferenceable(24) %7, i32 noundef %56, i32 noundef %58, i32 noundef 3)
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  store i32 0, ptr %8, align 4, !tbaa !23
  br label %59

59:                                               ; preds = %87, %54
  %60 = load i32, ptr %8, align 4, !tbaa !23
  %61 = getelementptr inbounds %class.RGBDSurface, ptr %14, i32 0, i32 5
  %62 = load i32, ptr %61, align 4, !tbaa !22
  %63 = icmp slt i32 %60, %62
  br i1 %63, label %65, label %64

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

65:                                               ; preds = %59
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  store i32 0, ptr %10, align 4, !tbaa !23
  br label %66

66:                                               ; preds = %79, %65
  %67 = load i32, ptr %10, align 4, !tbaa !23
  %68 = getelementptr inbounds %class.RGBDSurface, ptr %14, i32 0, i32 4
  %69 = load i32, ptr %68, align 8, !tbaa !21
  %70 = icmp slt i32 %67, %69
  br i1 %70, label %72, label %71

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

72:                                               ; preds = %66
  call void @llvm.lifetime.start.p0(i64 24, ptr %11) #5
  %73 = load i32, ptr %10, align 4, !tbaa !23
  %74 = load i32, ptr %8, align 4, !tbaa !23
  invoke void @_ZNK11RGBDSurface10TexelColorEii(ptr dead_on_unwind writable sret(%class.RNRgb) align 8 %11, ptr noundef nonnull align 8 dereferenceable(144) %14, i32 noundef %73, i32 noundef %74)
          to label %75 unwind label %82

75:                                               ; preds = %72
  %76 = load i32, ptr %10, align 4, !tbaa !23
  %77 = load i32, ptr %8, align 4, !tbaa !23
  invoke void @_ZN7R2Image11SetPixelRGBEiiRK5RNRgb(ptr noundef nonnull align 8 dereferenceable(24) %7, i32 noundef %76, i32 noundef %77, ptr noundef nonnull align 8 dereferenceable(24) %11)
          to label %78 unwind label %82

78:                                               ; preds = %75
  call void @llvm.lifetime.end.p0(i64 24, ptr %11) #5
  br label %79

79:                                               ; preds = %78
  %80 = load i32, ptr %10, align 4, !tbaa !23
  %81 = add nsw i32 %80, 1
  store i32 %81, ptr %10, align 4, !tbaa !23
  br label %66, !llvm.loop !24

82:                                               ; preds = %75, %72
  %83 = landingpad { ptr, i32 }
          cleanup
  %84 = extractvalue { ptr, i32 } %83, 0
  store ptr %84, ptr %12, align 8
  %85 = extractvalue { ptr, i32 } %83, 1
  store i32 %85, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 24, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  br label %102

86:                                               ; preds = %71
  br label %87

87:                                               ; preds = %86
  %88 = load i32, ptr %8, align 4, !tbaa !23
  %89 = add nsw i32 %88, 1
  store i32 %89, ptr %8, align 4, !tbaa !23
  br label %59, !llvm.loop !26

90:                                               ; preds = %64
  %91 = getelementptr inbounds [4096 x i8], ptr %5, i64 0, i64 0
  %92 = invoke noundef i32 @_ZNK7R2Image5WriteEPKc(ptr noundef nonnull align 8 dereferenceable(24) %7, ptr noundef %91)
          to label %93 unwind label %96

93:                                               ; preds = %90
  %94 = icmp ne i32 %92, 0
  br i1 %94, label %100, label %95

95:                                               ; preds = %93
  store i32 0, ptr %2, align 4
  store i32 1, ptr %9, align 4
  br label %101

96:                                               ; preds = %90
  %97 = landingpad { ptr, i32 }
          cleanup
  %98 = extractvalue { ptr, i32 } %97, 0
  store ptr %98, ptr %12, align 8
  %99 = extractvalue { ptr, i32 } %97, 1
  store i32 %99, ptr %13, align 4
  br label %102

100:                                              ; preds = %93
  store i32 1, ptr %2, align 4
  store i32 1, ptr %9, align 4
  br label %101

101:                                              ; preds = %100, %95
  call void @_ZN7R2ImageD1Ev(ptr noundef nonnull align 8 dereferenceable(24) %7) #5
  call void @llvm.lifetime.end.p0(i64 24, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 4096, ptr %5) #5
  br label %103

102:                                              ; preds = %96, %82
  call void @_ZN7R2ImageD1Ev(ptr noundef nonnull align 8 dereferenceable(24) %7) #5
  call void @llvm.lifetime.end.p0(i64 24, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 4096, ptr %5) #5
  br label %105

103:                                              ; preds = %101, %17
  %104 = load i32, ptr %2, align 4
  ret i32 %104

105:                                              ; preds = %102
  %106 = load ptr, ptr %12, align 8
  %107 = load i32, ptr %13, align 4
  %108 = insertvalue { ptr, i32 } poison, ptr %106, 0
  %109 = insertvalue { ptr, i32 } %108, i32 %107, 1
  resume { ptr, i32 } %109
}

declare void @_ZN7R2Image11SetPixelRGBEiiRK5RNRgb(ptr noundef nonnull align 8 dereferenceable(24), i32 noundef, i32 noundef, ptr noundef nonnull align 8 dereferenceable(24)) #3

declare noundef i32 @_ZNK7R2Image5WriteEPKc(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { inlinehint mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { "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 = { 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, !6, i64 56}
!10 = !{!"_ZTS11RGBDSurface", !6, i64 8, !11, i64 16, !12, i64 24, !11, i64 40, !11, i64 44, !11, i64 48, !6, i64 56, !6, i64 64, !14, i64 72, !11, i64 112, !6, i64 120, !6, i64 128, !6, i64 136}
!11 = !{!"int", !7, i64 0}
!12 = !{!"_ZTS7RNArrayIP6R2GridE", !13, i64 0}
!13 = !{!"_ZTS8RNVArray", !6, i64 0, !11, i64 8, !11, i64 12}
!14 = !{!"_ZTS5R2Box", !15, i64 0, !17, i64 8, !17, i64 24}
!15 = !{!"_ZTS7R2Solid", !16, i64 0}
!16 = !{!"_ZTS7R2Shape"}
!17 = !{!"_ZTS7R2Point", !7, i64 0}
!18 = !{!19, !19, i64 0}
!19 = !{!"vtable pointer", !8, i64 0}
!20 = !{!10, !6, i64 8}
!21 = !{!10, !11, i64 40}
!22 = !{!10, !11, i64 44}
!23 = !{!11, !11, i64 0}
!24 = distinct !{!24, !25}
!25 = !{!"llvm.loop.mustprogress"}
!26 = distinct !{!26, !25}


; 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.RNRgb = type { [3 x double] }
%class.R2Image = type { i32, i32, i32, i32, ptr }

@.str.6 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [10 x i8], align 1

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: mustprogress uwtable
declare dso_local void @_ZNK11RGBDSurface10TexelColorEii(ptr dead_on_unwind noalias writable sret(%class.RNRgb) align 8, ptr noundef nonnull align 8 dereferenceable(144), i32 noundef, i32 noundef) local_unnamed_addr #1 align 2

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

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

declare void @_ZN7R2ImageC1Eiii(ptr noundef nonnull align 8 dereferenceable(24), i32 noundef, i32 noundef, i32 noundef) unnamed_addr #3

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

; Function Attrs: nofree nounwind
declare noundef i32 @sprintf(ptr noalias nocapture noundef writeonly, ptr nocapture noundef readonly, ...) local_unnamed_addr #4

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

; Function Attrs: mustprogress uwtable
define dso_local noundef range(i32 0, 2) i32 @_ZN11RGBDSurface18WriteColorChannelsEv(ptr noundef nonnull align 8 dereferenceable(144) %0) unnamed_addr #1 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca [4096 x i8], align 16
  %3 = alloca [4096 x i8], align 16
  %4 = alloca %class.R2Image, align 8
  %5 = alloca %class.RNRgb, align 8
  %6 = tail call noundef i32 @_ZNK11RGBDSurface9NChannelsEv(ptr noundef nonnull align 8 dereferenceable(144) %0)
  %7 = icmp slt i32 %6, 3
  br i1 %7, label %54, label %8

8:                                                ; preds = %1
  %9 = getelementptr inbounds i8, ptr %0, i64 56
  %10 = load ptr, ptr %9, align 8, !tbaa !5
  %.not = icmp eq ptr %10, null
  br i1 %.not, label %11, label %17

11:                                               ; preds = %8
  call void @llvm.lifetime.start.p0(i64 4096, ptr nonnull %2) #6
  %12 = tail call noundef i32 @_ZNK11RGBDSurface18ConfigurationIndexEv(ptr noundef nonnull align 8 dereferenceable(144) %0)
  %13 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) %2, ptr noundef nonnull dereferenceable(1) @.str.9, i32 noundef %12) #6
  %14 = load ptr, ptr %0, align 8, !tbaa !17
  %15 = getelementptr inbounds i8, ptr %14, i64 184
  %16 = load ptr, ptr %15, align 8
  call void %16(ptr noundef nonnull align 8 dereferenceable(144) %0, ptr noundef nonnull %2)
  call void @llvm.lifetime.end.p0(i64 4096, ptr nonnull %2) #6
  br label %17

17:                                               ; preds = %11, %8
  call void @llvm.lifetime.start.p0(i64 4096, ptr nonnull %3) #6
  %18 = getelementptr inbounds i8, ptr %0, i64 8
  %19 = load ptr, ptr %18, align 8, !tbaa !19
  %.not19 = icmp eq ptr %19, null
  br i1 %.not19, label %..thread_crit_edge, label %20

..thread_crit_edge:                               ; preds = %17
  %.pre = load ptr, ptr %9, align 8, !tbaa !5
  br label %.thread

20:                                               ; preds = %17
  %21 = call noundef ptr @_ZNK17RGBDConfiguration16TextureDirectoryEv(ptr noundef nonnull align 8 dereferenceable(128) %19)
  %.not20 = icmp eq ptr %21, null
  %.pre28 = load ptr, ptr %9, align 8, !tbaa !5
  br i1 %.not20, label %.thread, label %22

22:                                               ; preds = %20
  %23 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) %3, ptr noundef nonnull dereferenceable(1) @.str.6, ptr noundef nonnull %21, ptr noundef %.pre28) #6
  br label %26

.thread:                                          ; preds = %..thread_crit_edge, %20
  %24 = phi ptr [ %.pre, %..thread_crit_edge ], [ %.pre28, %20 ]
  %25 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) %3, ptr noundef nonnull dereferenceable(1) @.str.7, ptr noundef %24) #6
  br label %26

26:                                               ; preds = %.thread, %22
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %4) #6
  %27 = getelementptr inbounds i8, ptr %0, i64 40
  %28 = load i32, ptr %27, align 8, !tbaa !20
  %29 = getelementptr inbounds i8, ptr %0, i64 44
  %30 = load i32, ptr %29, align 4, !tbaa !21
  call void @_ZN7R2ImageC1Eiii(ptr noundef nonnull align 8 dereferenceable(24) %4, i32 noundef %28, i32 noundef %30, i32 noundef 3)
  %31 = load i32, ptr %29, align 4, !tbaa !21
  %32 = icmp sgt i32 %31, 0
  %33 = load i32, ptr %27, align 8
  %34 = icmp sgt i32 %33, 0
  %or.cond = select i1 %32, i1 %34, i1 false
  br i1 %or.cond, label %.preheader, label %._crit_edge26

.preheader:                                       ; preds = %26, %._crit_edge
  %35 = phi i32 [ %39, %._crit_edge ], [ %31, %26 ]
  %36 = phi i32 [ %40, %._crit_edge ], [ %33, %26 ]
  %.01525 = phi i32 [ %41, %._crit_edge ], [ 0, %26 ]
  %37 = icmp sgt i32 %36, 0
  br i1 %37, label %.lr.ph, label %._crit_edge

._crit_edge26:                                    ; preds = %._crit_edge, %26
  %38 = invoke noundef i32 @_ZNK7R2Image5WriteEPKc(ptr noundef nonnull align 8 dereferenceable(24) %4, ptr noundef nonnull %3)
          to label %50 unwind label %51

._crit_edge.loopexit:                             ; preds = %44
  %.pre29 = load i32, ptr %29, align 4, !tbaa !21
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %.preheader
  %39 = phi i32 [ %.pre29, %._crit_edge.loopexit ], [ %35, %.preheader ]
  %40 = phi i32 [ %46, %._crit_edge.loopexit ], [ %36, %.preheader ]
  %41 = add nuw nsw i32 %.01525, 1
  %42 = icmp slt i32 %41, %39
  br i1 %42, label %.preheader, label %._crit_edge26, !llvm.loop !22

.lr.ph:                                           ; preds = %.preheader, %44
  %.01424 = phi i32 [ %45, %44 ], [ 0, %.preheader ]
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %5) #6
  invoke void @_ZNK11RGBDSurface10TexelColorEii(ptr dead_on_unwind nonnull writable sret(%class.RNRgb) align 8 %5, ptr noundef nonnull align 8 dereferenceable(144) %0, i32 noundef %.01424, i32 noundef %.01525)
          to label %43 unwind label %48

43:                                               ; preds = %.lr.ph
  invoke void @_ZN7R2Image11SetPixelRGBEiiRK5RNRgb(ptr noundef nonnull align 8 dereferenceable(24) %4, i32 noundef %.01424, i32 noundef %.01525, ptr noundef nonnull align 8 dereferenceable(24) %5)
          to label %44 unwind label %48

44:                                               ; preds = %43
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %5) #6
  %45 = add nuw nsw i32 %.01424, 1
  %46 = load i32, ptr %27, align 8, !tbaa !20
  %47 = icmp slt i32 %45, %46
  br i1 %47, label %.lr.ph, label %._crit_edge.loopexit, !llvm.loop !25

48:                                               ; preds = %43, %.lr.ph
  %49 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %5) #6
  br label %53

50:                                               ; preds = %._crit_edge26
  %.not21 = icmp ne i32 %38, 0
  %. = zext i1 %.not21 to i32
  call void @_ZN7R2ImageD1Ev(ptr noundef nonnull align 8 dereferenceable(24) %4) #6
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %4) #6
  call void @llvm.lifetime.end.p0(i64 4096, ptr nonnull %3) #6
  br label %54

51:                                               ; preds = %._crit_edge26
  %52 = landingpad { ptr, i32 }
          cleanup
  br label %53

53:                                               ; preds = %51, %48
  %.pn = phi { ptr, i32 } [ %49, %48 ], [ %52, %51 ]
  call void @_ZN7R2ImageD1Ev(ptr noundef nonnull align 8 dereferenceable(24) %4) #6
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %4) #6
  call void @llvm.lifetime.end.p0(i64 4096, ptr nonnull %3) #6
  resume { ptr, i32 } %.pn

54:                                               ; preds = %1, %50
  %.1 = phi i32 [ %., %50 ], [ 0, %1 ]
  ret i32 %.1
}

declare void @_ZN7R2Image11SetPixelRGBEiiRK5RNRgb(ptr noundef nonnull align 8 dereferenceable(24), i32 noundef, i32 noundef, ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #3

declare noundef i32 @_ZNK7R2Image5WriteEPKc(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef) local_unnamed_addr #3

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { inlinehint mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { "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 = { nofree 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 = { 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 = { 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, !7, i64 56}
!6 = !{!"_ZTS11RGBDSurface", !7, i64 8, !10, i64 16, !11, i64 24, !10, i64 40, !10, i64 44, !10, i64 48, !7, i64 56, !7, i64 64, !13, i64 72, !10, i64 112, !7, i64 120, !7, i64 128, !7, i64 136}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"_ZTS7RNArrayIP6R2GridE", !12, i64 0}
!12 = !{!"_ZTS8RNVArray", !7, i64 0, !10, i64 8, !10, i64 12}
!13 = !{!"_ZTS5R2Box", !14, i64 0, !16, i64 8, !16, i64 24}
!14 = !{!"_ZTS7R2Solid", !15, i64 0}
!15 = !{!"_ZTS7R2Shape"}
!16 = !{!"_ZTS7R2Point", !8, i64 0}
!17 = !{!18, !18, i64 0}
!18 = !{!"vtable pointer", !9, i64 0}
!19 = !{!6, !7, i64 8}
!20 = !{!6, !10, i64 40}
!21 = !{!6, !10, i64 44}
!22 = distinct !{!22, !23, !24}
!23 = !{!"llvm.loop.mustprogress"}
!24 = !{!"llvm.loop.unswitch.partial.disable"}
!25 = distinct !{!25, !23}


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