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

; 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.RGBDImage = type { ptr, ptr, i32, %class.RNArray, i32, i32, %class.R3Affine, %class.R3Matrix, %class.R3Box, i32, ptr, ptr, ptr, i32, i32 }
%class.RNArray = type { %class.RNVArray }
%class.RNVArray = type { ptr, i32, i32 }
%class.R3Affine = type { %class.R3Transformation, %class.R4Matrix, %class.R4Matrix, %class.RNFlags }
%class.R3Transformation = type { ptr }
%class.R4Matrix = type { [4 x [4 x double]] }
%class.RNFlags = type { i64 }
%class.R3Matrix = type { [3 x [3 x double]] }
%class.R3Box = type { %class.R3Solid, %class.R3Point, %class.R3Point }
%class.R3Solid = type { %class.R3Shape }
%class.R3Shape = type { ptr }
%class.R3Point = type { [3 x double] }

@.str.4 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [3 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

declare i32 @__gxx_personality_v0(...)

; 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 @_ZNK9RGBDImage10PixelColorEii(ptr dead_on_unwind noalias writable sret(%class.RNRgb) align 8, ptr noundef nonnull align 8 dereferenceable(488), i32 noundef, i32 noundef) #1 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK9RGBDImage9NChannelsEv(ptr noundef nonnull align 8 dereferenceable(488)) #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 @_ZNK17RGBDConfiguration14ColorDirectoryEv(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 @_ZN9RGBDImage18WriteColorChannelsEv(ptr noundef nonnull align 8 dereferenceable(488) %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 ptr, align 8
  %6 = alloca %class.R2Image, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca %class.RNRgb, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  %13 = load ptr, ptr %3, align 8
  %14 = getelementptr inbounds %class.RGBDImage, ptr %13, i32 0, i32 11
  %15 = load ptr, ptr %14, align 8, !tbaa !9
  %16 = icmp ne ptr %15, null
  br i1 %16, label %18, label %17

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

18:                                               ; preds = %1
  %19 = call noundef i32 @_ZNK9RGBDImage9NChannelsEv(ptr noundef nonnull align 8 dereferenceable(488) %13)
  %20 = icmp sle i32 %19, 2
  br i1 %20, label %21, label %22

21:                                               ; preds = %18
  store i32 0, ptr %2, align 4
  br label %96

22:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 4096, ptr %4) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  %23 = getelementptr inbounds %class.RGBDImage, ptr %13, i32 0, i32 1
  %24 = load ptr, ptr %23, align 8, !tbaa !24
  %25 = icmp ne ptr %24, null
  br i1 %25, label %26, label %30

26:                                               ; preds = %22
  %27 = getelementptr inbounds %class.RGBDImage, ptr %13, i32 0, i32 1
  %28 = load ptr, ptr %27, align 8, !tbaa !24
  %29 = call noundef ptr @_ZNK17RGBDConfiguration14ColorDirectoryEv(ptr noundef nonnull align 8 dereferenceable(128) %28)
  br label %31

30:                                               ; preds = %22
  br label %31

31:                                               ; preds = %30, %26
  %32 = phi ptr [ %29, %26 ], [ null, %30 ]
  store ptr %32, ptr %5, align 8, !tbaa !5
  %33 = load ptr, ptr %5, align 8, !tbaa !5
  %34 = icmp ne ptr %33, null
  br i1 %34, label %35, label %41

35:                                               ; preds = %31
  %36 = getelementptr inbounds [4096 x i8], ptr %4, i64 0, i64 0
  %37 = load ptr, ptr %5, align 8, !tbaa !5
  %38 = getelementptr inbounds %class.RGBDImage, ptr %13, i32 0, i32 11
  %39 = load ptr, ptr %38, align 8, !tbaa !9
  %40 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef %36, ptr noundef @.str.4, ptr noundef %37, ptr noundef %39) #5
  br label %46

41:                                               ; preds = %31
  %42 = getelementptr inbounds [4096 x i8], ptr %4, i64 0, i64 0
  %43 = getelementptr inbounds %class.RGBDImage, ptr %13, i32 0, i32 11
  %44 = load ptr, ptr %43, align 8, !tbaa !9
  %45 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef %42, ptr noundef @.str.5, ptr noundef %44) #5
  br label %46

46:                                               ; preds = %41, %35
  call void @llvm.lifetime.start.p0(i64 24, ptr %6) #5
  %47 = getelementptr inbounds %class.RGBDImage, ptr %13, i32 0, i32 4
  %48 = load i32, ptr %47, align 8, !tbaa !25
  %49 = getelementptr inbounds %class.RGBDImage, ptr %13, i32 0, i32 5
  %50 = load i32, ptr %49, align 4, !tbaa !26
  call void @_ZN7R2ImageC1Eiii(ptr noundef nonnull align 8 dereferenceable(24) %6, i32 noundef %48, i32 noundef %50, i32 noundef 3)
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  store i32 0, ptr %7, align 4, !tbaa !27
  br label %51

51:                                               ; preds = %79, %46
  %52 = load i32, ptr %7, align 4, !tbaa !27
  %53 = getelementptr inbounds %class.RGBDImage, ptr %13, i32 0, i32 5
  %54 = load i32, ptr %53, align 4, !tbaa !26
  %55 = icmp slt i32 %52, %54
  br i1 %55, label %57, label %56

56:                                               ; preds = %51
  store i32 2, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  br label %82

57:                                               ; preds = %51
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  store i32 0, ptr %9, align 4, !tbaa !27
  br label %58

58:                                               ; preds = %71, %57
  %59 = load i32, ptr %9, align 4, !tbaa !27
  %60 = getelementptr inbounds %class.RGBDImage, ptr %13, i32 0, i32 4
  %61 = load i32, ptr %60, align 8, !tbaa !25
  %62 = icmp slt i32 %59, %61
  br i1 %62, label %64, label %63

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

64:                                               ; preds = %58
  call void @llvm.lifetime.start.p0(i64 24, ptr %10) #5
  %65 = load i32, ptr %9, align 4, !tbaa !27
  %66 = load i32, ptr %7, align 4, !tbaa !27
  invoke void @_ZNK9RGBDImage10PixelColorEii(ptr dead_on_unwind writable sret(%class.RNRgb) align 8 %10, ptr noundef nonnull align 8 dereferenceable(488) %13, i32 noundef %65, i32 noundef %66)
          to label %67 unwind label %74

67:                                               ; preds = %64
  %68 = load i32, ptr %9, align 4, !tbaa !27
  %69 = load i32, ptr %7, align 4, !tbaa !27
  invoke void @_ZN7R2Image11SetPixelRGBEiiRK5RNRgb(ptr noundef nonnull align 8 dereferenceable(24) %6, i32 noundef %68, i32 noundef %69, ptr noundef nonnull align 8 dereferenceable(24) %10)
          to label %70 unwind label %74

70:                                               ; preds = %67
  call void @llvm.lifetime.end.p0(i64 24, ptr %10) #5
  br label %71

71:                                               ; preds = %70
  %72 = load i32, ptr %9, align 4, !tbaa !27
  %73 = add nsw i32 %72, 1
  store i32 %73, ptr %9, align 4, !tbaa !27
  br label %58, !llvm.loop !28

74:                                               ; preds = %67, %64
  %75 = landingpad { ptr, i32 }
          cleanup
  %76 = extractvalue { ptr, i32 } %75, 0
  store ptr %76, ptr %11, align 8
  %77 = extractvalue { ptr, i32 } %75, 1
  store i32 %77, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 24, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  br label %95

78:                                               ; preds = %63
  br label %79

79:                                               ; preds = %78
  %80 = load i32, ptr %7, align 4, !tbaa !27
  %81 = add nsw i32 %80, 1
  store i32 %81, ptr %7, align 4, !tbaa !27
  br label %51, !llvm.loop !30

82:                                               ; preds = %56
  %83 = getelementptr inbounds %class.RGBDImage, ptr %13, i32 0, i32 11
  %84 = load ptr, ptr %83, align 8, !tbaa !9
  %85 = invoke noundef i32 @_ZNK7R2Image5WriteEPKc(ptr noundef nonnull align 8 dereferenceable(24) %6, ptr noundef %84)
          to label %86 unwind label %89

86:                                               ; preds = %82
  %87 = icmp ne i32 %85, 0
  br i1 %87, label %93, label %88

88:                                               ; preds = %86
  store i32 0, ptr %2, align 4
  store i32 1, ptr %8, align 4
  br label %94

89:                                               ; preds = %82
  %90 = landingpad { ptr, i32 }
          cleanup
  %91 = extractvalue { ptr, i32 } %90, 0
  store ptr %91, ptr %11, align 8
  %92 = extractvalue { ptr, i32 } %90, 1
  store i32 %92, ptr %12, align 4
  br label %95

93:                                               ; preds = %86
  store i32 1, ptr %2, align 4
  store i32 1, ptr %8, align 4
  br label %94

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

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

96:                                               ; preds = %94, %21, %17
  %97 = load i32, ptr %2, align 4
  ret i32 %97

98:                                               ; preds = %95
  %99 = load ptr, ptr %11, align 8
  %100 = load i32, ptr %12, align 4
  %101 = insertvalue { ptr, i32 } poison, ptr %99, 0
  %102 = insertvalue { ptr, i32 } %101, i32 %100, 1
  resume { ptr, i32 } %102
}

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 464}
!10 = !{!"_ZTS9RGBDImage", !6, i64 8, !11, i64 16, !12, i64 24, !11, i64 40, !11, i64 44, !14, i64 48, !19, i64 320, !20, i64 392, !11, i64 448, !6, i64 456, !6, i64 464, !6, i64 472, !11, i64 480, !11, i64 484}
!11 = !{!"int", !7, i64 0}
!12 = !{!"_ZTS7RNArrayIP6R2GridE", !13, i64 0}
!13 = !{!"_ZTS8RNVArray", !6, i64 0, !11, i64 8, !11, i64 12}
!14 = !{!"_ZTS8R3Affine", !15, i64 0, !16, i64 8, !16, i64 136, !17, i64 264}
!15 = !{!"_ZTS16R3Transformation"}
!16 = !{!"_ZTS8R4Matrix", !7, i64 0}
!17 = !{!"_ZTS7RNFlags", !18, i64 0}
!18 = !{!"long", !7, i64 0}
!19 = !{!"_ZTS8R3Matrix", !7, i64 0}
!20 = !{!"_ZTS5R3Box", !21, i64 0, !23, i64 8, !23, i64 32}
!21 = !{!"_ZTS7R3Solid", !22, i64 0}
!22 = !{!"_ZTS7R3Shape"}
!23 = !{!"_ZTS7R3Point", !7, i64 0}
!24 = !{!10, !6, i64 8}
!25 = !{!10, !11, i64 40}
!26 = !{!10, !11, i64 44}
!27 = !{!11, !11, i64 0}
!28 = distinct !{!28, !29}
!29 = !{!"llvm.loop.mustprogress"}
!30 = distinct !{!30, !29}


; 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.4 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [3 x i8], align 1

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

declare i32 @__gxx_personality_v0(...)

; 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 @_ZNK9RGBDImage10PixelColorEii(ptr dead_on_unwind noalias writable sret(%class.RNRgb) align 8, ptr noundef nonnull align 8 dereferenceable(488), i32 noundef, i32 noundef) local_unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK9RGBDImage9NChannelsEv(ptr noundef nonnull align 8 dereferenceable(488)) 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 @_ZNK17RGBDConfiguration14ColorDirectoryEv(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 @_ZN9RGBDImage18WriteColorChannelsEv(ptr noundef nonnull align 8 dereferenceable(488) %0) unnamed_addr #1 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca [4096 x i8], align 16
  %3 = alloca %class.R2Image, align 8
  %4 = alloca %class.RNRgb, align 8
  %5 = getelementptr inbounds i8, ptr %0, i64 464
  %6 = load ptr, ptr %5, align 8, !tbaa !5
  %.not = icmp eq ptr %6, null
  br i1 %.not, label %49, label %7

7:                                                ; preds = %1
  %8 = tail call noundef i32 @_ZNK9RGBDImage9NChannelsEv(ptr noundef nonnull align 8 dereferenceable(488) %0)
  %9 = icmp slt i32 %8, 3
  br i1 %9, label %49, label %10

10:                                               ; preds = %7
  call void @llvm.lifetime.start.p0(i64 4096, ptr nonnull %2) #6
  %11 = getelementptr inbounds i8, ptr %0, i64 8
  %12 = load ptr, ptr %11, align 8, !tbaa !23
  %.not19 = icmp eq ptr %12, null
  br i1 %.not19, label %.thread, label %13

13:                                               ; preds = %10
  %14 = tail call noundef ptr @_ZNK17RGBDConfiguration14ColorDirectoryEv(ptr noundef nonnull align 8 dereferenceable(128) %12)
  %.not20 = icmp eq ptr %14, null
  br i1 %.not20, label %.thread, label %15

15:                                               ; preds = %13
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) %2, ptr noundef nonnull dereferenceable(1) @.str.4, ptr noundef nonnull %14, ptr noundef %16) #6
  br label %20

.thread:                                          ; preds = %10, %13
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) %2, ptr noundef nonnull dereferenceable(1) @.str.5, ptr noundef %18) #6
  br label %20

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

.preheader:                                       ; preds = %20, %._crit_edge
  %29 = phi i32 [ %34, %._crit_edge ], [ %25, %20 ]
  %30 = phi i32 [ %35, %._crit_edge ], [ %27, %20 ]
  %.01525 = phi i32 [ %36, %._crit_edge ], [ 0, %20 ]
  %31 = icmp sgt i32 %30, 0
  br i1 %31, label %.lr.ph, label %._crit_edge

._crit_edge26:                                    ; preds = %._crit_edge, %20
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  %33 = invoke noundef i32 @_ZNK7R2Image5WriteEPKc(ptr noundef nonnull align 8 dereferenceable(24) %3, ptr noundef %32)
          to label %45 unwind label %46

._crit_edge.loopexit:                             ; preds = %39
  %.pre = load i32, ptr %23, align 4, !tbaa !25
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %.preheader
  %34 = phi i32 [ %.pre, %._crit_edge.loopexit ], [ %29, %.preheader ]
  %35 = phi i32 [ %41, %._crit_edge.loopexit ], [ %30, %.preheader ]
  %36 = add nuw nsw i32 %.01525, 1
  %37 = icmp slt i32 %36, %34
  br i1 %37, label %.preheader, label %._crit_edge26, !llvm.loop !26

.lr.ph:                                           ; preds = %.preheader, %39
  %.01424 = phi i32 [ %40, %39 ], [ 0, %.preheader ]
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %4) #6
  invoke void @_ZNK9RGBDImage10PixelColorEii(ptr dead_on_unwind nonnull writable sret(%class.RNRgb) align 8 %4, ptr noundef nonnull align 8 dereferenceable(488) %0, i32 noundef %.01424, i32 noundef %.01525)
          to label %38 unwind label %43

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

39:                                               ; preds = %38
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %4) #6
  %40 = add nuw nsw i32 %.01424, 1
  %41 = load i32, ptr %21, align 8, !tbaa !24
  %42 = icmp slt i32 %40, %41
  br i1 %42, label %.lr.ph, label %._crit_edge.loopexit, !llvm.loop !29

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

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

46:                                               ; preds = %._crit_edge26
  %47 = landingpad { ptr, i32 }
          cleanup
  br label %48

48:                                               ; preds = %46, %43
  %.pn = phi { ptr, i32 } [ %44, %43 ], [ %47, %46 ]
  call void @_ZN7R2ImageD1Ev(ptr noundef nonnull align 8 dereferenceable(24) %3) #6
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %3) #6
  call void @llvm.lifetime.end.p0(i64 4096, ptr nonnull %2) #6
  resume { ptr, i32 } %.pn

49:                                               ; preds = %7, %1, %45
  %.1 = phi i32 [ %., %45 ], [ 0, %1 ], [ 0, %7 ]
  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 464}
!6 = !{!"_ZTS9RGBDImage", !7, i64 8, !10, i64 16, !11, i64 24, !10, i64 40, !10, i64 44, !13, i64 48, !18, i64 320, !19, i64 392, !10, i64 448, !7, i64 456, !7, i64 464, !7, i64 472, !10, i64 480, !10, i64 484}
!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 = !{!"_ZTS8R3Affine", !14, i64 0, !15, i64 8, !15, i64 136, !16, i64 264}
!14 = !{!"_ZTS16R3Transformation"}
!15 = !{!"_ZTS8R4Matrix", !8, i64 0}
!16 = !{!"_ZTS7RNFlags", !17, i64 0}
!17 = !{!"long", !8, i64 0}
!18 = !{!"_ZTS8R3Matrix", !8, i64 0}
!19 = !{!"_ZTS5R3Box", !20, i64 0, !22, i64 8, !22, i64 32}
!20 = !{!"_ZTS7R3Solid", !21, i64 0}
!21 = !{!"_ZTS7R3Shape"}
!22 = !{!"_ZTS7R3Point", !8, i64 0}
!23 = !{!6, !7, i64 8}
!24 = !{!6, !10, i64 40}
!25 = !{!6, !10, i64 44}
!26 = distinct !{!26, !27, !28}
!27 = !{!"llvm.loop.mustprogress"}
!28 = !{!"llvm.loop.unswitch.partial.disable"}
!29 = distinct !{!29, !27}


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