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

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

@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 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: inlinehint mustprogress uwtable
declare dso_local noundef double @_ZNK6R2Grid9GridValueEii(ptr noundef nonnull align 8 dereferenceable(208), i32 noundef, i32 noundef) #1 align 2

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK6R2Grid5RangeEv(ptr dead_on_unwind noalias writable sret(%class.RNInterval) align 8, ptr noundef nonnull align 8 dereferenceable(208)) #3 align 2

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

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

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

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZNK6R2Grid10WriteImageEPKc(ptr noundef nonnull align 8 dereferenceable(208) %0, ptr noundef %1) #3 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 %class.RNInterval, align 8
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca double, align 8
  %14 = alloca %class.RNRgb, align 8
  %15 = alloca %class.RNRgb, align 8
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %18 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #8
  %19 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 24) #9
  %20 = getelementptr inbounds %class.R2Grid, ptr %18, i32 0, i32 4
  %21 = getelementptr inbounds [2 x i32], ptr %20, i64 0, i64 0
  %22 = load i32, ptr %21, align 8, !tbaa !9
  %23 = getelementptr inbounds %class.R2Grid, ptr %18, i32 0, i32 4
  %24 = getelementptr inbounds [2 x i32], ptr %23, i64 0, i64 1
  %25 = load i32, ptr %24, align 4, !tbaa !9
  invoke void @_ZN7R2ImageC1Eiii(ptr noundef nonnull align 8 dereferenceable(24) %19, i32 noundef %22, i32 noundef %25, i32 noundef 3)
          to label %26 unwind label %33

26:                                               ; preds = %2
  store ptr %19, ptr %6, align 8, !tbaa !5
  %27 = load ptr, ptr %6, align 8, !tbaa !5
  %28 = icmp ne ptr %27, null
  br i1 %28, label %37, label %29

29:                                               ; preds = %26
  %30 = load ptr, ptr @stderr, align 8, !tbaa !5
  %31 = load ptr, ptr %5, align 8, !tbaa !5
  %32 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %30, ptr noundef @.str.79, ptr noundef %31) #8
  store i32 0, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %125

33:                                               ; preds = %2
  %34 = landingpad { ptr, i32 }
          cleanup
  %35 = extractvalue { ptr, i32 } %34, 0
  store ptr %35, ptr %7, align 8
  %36 = extractvalue { ptr, i32 } %34, 1
  store i32 %36, ptr %8, align 4
  call void @_ZdlPvm(ptr noundef %19, i64 noundef 24) #10
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #8
  br label %127

37:                                               ; preds = %26
  call void @llvm.lifetime.start.p0(i64 16, ptr %10) #8
  call void @_ZNK6R2Grid5RangeEv(ptr dead_on_unwind writable sret(%class.RNInterval) align 8 %10, ptr noundef nonnull align 8 dereferenceable(208) %18)
  %38 = call noundef double @_ZNK10RNInterval8DiameterEv(ptr noundef nonnull align 8 dereferenceable(16) %10)
  %39 = fcmp ogt double %38, 0.000000e+00
  br i1 %39, label %40, label %78

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

41:                                               ; preds = %74, %40
  %42 = load i32, ptr %11, align 4, !tbaa !9
  %43 = load ptr, ptr %6, align 8, !tbaa !5
  %44 = call noundef i32 @_ZNK7R2Image6HeightEv(ptr noundef nonnull align 8 dereferenceable(24) %43)
  %45 = icmp slt i32 %42, %44
  br i1 %45, label %47, label %46

46:                                               ; preds = %41
  store i32 2, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #8
  br label %77

47:                                               ; preds = %41
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #8
  store i32 0, ptr %12, align 4, !tbaa !9
  br label %48

48:                                               ; preds = %70, %47
  %49 = load i32, ptr %12, align 4, !tbaa !9
  %50 = load ptr, ptr %6, align 8, !tbaa !5
  %51 = call noundef i32 @_ZNK7R2Image5WidthEv(ptr noundef nonnull align 8 dereferenceable(24) %50)
  %52 = icmp slt i32 %49, %51
  br i1 %52, label %54, label %53

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

54:                                               ; preds = %48
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #8
  %55 = load i32, ptr %12, align 4, !tbaa !9
  %56 = load i32, ptr %11, align 4, !tbaa !9
  %57 = call noundef double @_ZNK6R2Grid9GridValueEii(ptr noundef nonnull align 8 dereferenceable(208) %18, i32 noundef %55, i32 noundef %56)
  %58 = call noundef double @_ZNK10RNInterval3MinEv(ptr noundef nonnull align 8 dereferenceable(16) %10)
  %59 = fsub double %57, %58
  %60 = call noundef double @_ZNK10RNInterval3MaxEv(ptr noundef nonnull align 8 dereferenceable(16) %10)
  %61 = call noundef double @_ZNK10RNInterval3MinEv(ptr noundef nonnull align 8 dereferenceable(16) %10)
  %62 = fsub double %60, %61
  %63 = fdiv double %59, %62
  store double %63, ptr %13, align 8, !tbaa !11
  %64 = load ptr, ptr %6, align 8, !tbaa !5
  %65 = load i32, ptr %12, align 4, !tbaa !9
  %66 = load i32, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 24, ptr %14) #8
  %67 = load double, ptr %13, align 8, !tbaa !11
  %68 = load double, ptr %13, align 8, !tbaa !11
  %69 = load double, ptr %13, align 8, !tbaa !11
  call void @_ZN5RNRgbC1Eddd(ptr noundef nonnull align 8 dereferenceable(24) %14, double noundef %67, double noundef %68, double noundef %69)
  call void @_ZN7R2Image11SetPixelRGBEiiRK5RNRgb(ptr noundef nonnull align 8 dereferenceable(24) %64, i32 noundef %65, i32 noundef %66, ptr noundef nonnull align 8 dereferenceable(24) %14)
  call void @llvm.lifetime.end.p0(i64 24, ptr %14) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #8
  br label %70

70:                                               ; preds = %54
  %71 = load i32, ptr %12, align 4, !tbaa !9
  %72 = add nsw i32 %71, 1
  store i32 %72, ptr %12, align 4, !tbaa !9
  br label %48, !llvm.loop !13

73:                                               ; preds = %53
  br label %74

74:                                               ; preds = %73
  %75 = load i32, ptr %11, align 4, !tbaa !9
  %76 = add nsw i32 %75, 1
  store i32 %76, ptr %11, align 4, !tbaa !9
  br label %41, !llvm.loop !15

77:                                               ; preds = %46
  br label %78

78:                                               ; preds = %77, %37
  call void @llvm.lifetime.start.p0(i64 24, ptr %15) #8
  call void @_ZN5RNRgbC1Eddd(ptr noundef nonnull align 8 dereferenceable(24) %15, double noundef 1.000000e+00, double noundef 5.000000e-01, double noundef 0.000000e+00)
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #8
  store i32 0, ptr %16, align 4, !tbaa !9
  br label %79

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

84:                                               ; preds = %79
  store i32 8, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #8
  br label %109

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

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

91:                                               ; preds = %86
  store i32 11, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #8
  br label %105

92:                                               ; preds = %86
  %93 = load i32, ptr %17, align 4, !tbaa !9
  %94 = load i32, ptr %16, align 4, !tbaa !9
  %95 = call noundef double @_ZNK6R2Grid9GridValueEii(ptr noundef nonnull align 8 dereferenceable(208) %18, i32 noundef %93, i32 noundef %94)
  %96 = fcmp une double %95, -3.210000e+02
  br i1 %96, label %97, label %98

97:                                               ; preds = %92
  br label %102

98:                                               ; preds = %92
  %99 = load ptr, ptr %6, align 8, !tbaa !5
  %100 = load i32, ptr %17, align 4, !tbaa !9
  %101 = load i32, ptr %16, align 4, !tbaa !9
  call void @_ZN7R2Image11SetPixelRGBEiiRK5RNRgb(ptr noundef nonnull align 8 dereferenceable(24) %99, i32 noundef %100, i32 noundef %101, ptr noundef nonnull align 8 dereferenceable(24) %15)
  br label %102

102:                                              ; preds = %98, %97
  %103 = load i32, ptr %17, align 4, !tbaa !9
  %104 = add nsw i32 %103, 1
  store i32 %104, ptr %17, align 4, !tbaa !9
  br label %86, !llvm.loop !16

105:                                              ; preds = %91
  br label %106

106:                                              ; preds = %105
  %107 = load i32, ptr %16, align 4, !tbaa !9
  %108 = add nsw i32 %107, 1
  store i32 %108, ptr %16, align 4, !tbaa !9
  br label %79, !llvm.loop !17

109:                                              ; preds = %84
  %110 = load ptr, ptr %6, align 8, !tbaa !5
  %111 = load ptr, ptr %5, align 8, !tbaa !5
  %112 = call noundef i32 @_ZNK7R2Image5WriteEPKc(ptr noundef nonnull align 8 dereferenceable(24) %110, ptr noundef %111)
  %113 = icmp ne i32 %112, 0
  br i1 %113, label %119, label %114

114:                                              ; preds = %109
  %115 = load ptr, ptr %6, align 8, !tbaa !5
  %116 = icmp eq ptr %115, null
  br i1 %116, label %118, label %117

117:                                              ; preds = %114
  call void @_ZN7R2ImageD1Ev(ptr noundef nonnull align 8 dereferenceable(24) %115) #8
  call void @_ZdlPvm(ptr noundef %115, i64 noundef 24) #10
  br label %118

118:                                              ; preds = %117, %114
  store i32 0, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %124

119:                                              ; preds = %109
  %120 = load ptr, ptr %6, align 8, !tbaa !5
  %121 = icmp eq ptr %120, null
  br i1 %121, label %123, label %122

122:                                              ; preds = %119
  call void @_ZN7R2ImageD1Ev(ptr noundef nonnull align 8 dereferenceable(24) %120) #8
  call void @_ZdlPvm(ptr noundef %120, i64 noundef 24) #10
  br label %123

123:                                              ; preds = %122, %119
  store i32 1, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %124

124:                                              ; preds = %123, %118
  call void @llvm.lifetime.end.p0(i64 24, ptr %15) #8
  call void @llvm.lifetime.end.p0(i64 16, ptr %10) #8
  br label %125

125:                                              ; preds = %124, %29
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #8
  %126 = load i32, ptr %3, align 4
  ret i32 %126

127:                                              ; preds = %33
  %128 = load ptr, ptr %7, align 8
  %129 = load i32, ptr %8, align 4
  %130 = insertvalue { ptr, i32 } poison, ptr %128, 0
  %131 = insertvalue { ptr, i32 } %130, i32 %129, 1
  resume { ptr, i32 } %131
}

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

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

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

declare void @_ZN5RNRgbC1Eddd(ptr noundef nonnull align 8 dereferenceable(24), double noundef, double noundef, double noundef) unnamed_addr #7

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { 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 = { 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 #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 = { "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 = { nounwind }
attributes #9 = { builtin allocsize(0) }
attributes #10 = { 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, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = distinct !{!16, !14}
!17 = distinct !{!17, !14}


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

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: inlinehint mustprogress uwtable
declare dso_local noundef double @_ZNK6R2Grid9GridValueEii(ptr noundef nonnull align 8 dereferenceable(208), i32 noundef, i32 noundef) local_unnamed_addr #1 align 2

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK6R2Grid5RangeEv(ptr dead_on_unwind noalias writable sret(%class.RNInterval) align 8, ptr noundef nonnull align 8 dereferenceable(208)) local_unnamed_addr #3 align 2

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

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

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

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

; 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 @_ZNK6R2Grid10WriteImageEPKc(ptr noundef nonnull align 8 dereferenceable(208) %0, ptr noundef %1) local_unnamed_addr #3 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca %class.RNInterval, align 8
  %4 = alloca %class.RNRgb, align 8
  %5 = alloca %class.RNRgb, align 8
  %6 = tail call noalias noundef nonnull dereferenceable(24) ptr @_Znwm(i64 noundef 24) #8
  %7 = getelementptr inbounds i8, ptr %0, i64 192
  %8 = load i32, ptr %7, align 8, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %0, i64 196
  %10 = load i32, ptr %9, align 4, !tbaa !5
  invoke void @_ZN7R2ImageC1Eiii(ptr noundef nonnull align 8 dereferenceable(24) %6, i32 noundef %8, i32 noundef %10, i32 noundef 3)
          to label %13 unwind label %11

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

13:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %3) #10
  call void @_ZNK6R2Grid5RangeEv(ptr dead_on_unwind nonnull writable sret(%class.RNInterval) align 8 %3, ptr noundef nonnull align 8 dereferenceable(208) %0)
  %14 = call noundef double @_ZNK10RNInterval8DiameterEv(ptr noundef nonnull align 8 dereferenceable(16) %3)
  %15 = fcmp ogt double %14, 0.000000e+00
  br i1 %15, label %.preheader39, label %.loopexit

.preheader39:                                     ; preds = %13
  %16 = call noundef i32 @_ZNK7R2Image6HeightEv(ptr noundef nonnull align 8 dereferenceable(24) %6)
  %17 = icmp sgt i32 %16, 0
  br i1 %17, label %.preheader38, label %.loopexit

.preheader38:                                     ; preds = %.preheader39, %._crit_edge
  %.03741 = phi i32 [ %20, %._crit_edge ], [ 0, %.preheader39 ]
  %18 = call noundef i32 @_ZNK7R2Image5WidthEv(ptr noundef nonnull align 8 dereferenceable(24) %6)
  %19 = icmp sgt i32 %18, 0
  br i1 %19, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %.preheader38
  %20 = add nuw nsw i32 %.03741, 1
  %21 = call noundef i32 @_ZNK7R2Image6HeightEv(ptr noundef nonnull align 8 dereferenceable(24) %6)
  %22 = icmp slt i32 %20, %21
  br i1 %22, label %.preheader38, label %.loopexit, !llvm.loop !9

.lr.ph:                                           ; preds = %.preheader38, %.lr.ph
  %.03640 = phi i32 [ %30, %.lr.ph ], [ 0, %.preheader38 ]
  %23 = call noundef double @_ZNK6R2Grid9GridValueEii(ptr noundef nonnull align 8 dereferenceable(208) %0, i32 noundef %.03640, i32 noundef %.03741)
  %24 = call noundef double @_ZNK10RNInterval3MinEv(ptr noundef nonnull align 8 dereferenceable(16) %3)
  %25 = fsub double %23, %24
  %26 = call noundef double @_ZNK10RNInterval3MaxEv(ptr noundef nonnull align 8 dereferenceable(16) %3)
  %27 = call noundef double @_ZNK10RNInterval3MinEv(ptr noundef nonnull align 8 dereferenceable(16) %3)
  %28 = fsub double %26, %27
  %29 = fdiv double %25, %28
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %4) #10
  call void @_ZN5RNRgbC1Eddd(ptr noundef nonnull align 8 dereferenceable(24) %4, double noundef %29, double noundef %29, double noundef %29)
  call void @_ZN7R2Image11SetPixelRGBEiiRK5RNRgb(ptr noundef nonnull align 8 dereferenceable(24) %6, i32 noundef %.03640, i32 noundef %.03741, ptr noundef nonnull align 8 dereferenceable(24) %4)
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %4) #10
  %30 = add nuw nsw i32 %.03640, 1
  %31 = call noundef i32 @_ZNK7R2Image5WidthEv(ptr noundef nonnull align 8 dereferenceable(24) %6)
  %32 = icmp slt i32 %30, %31
  br i1 %32, label %.lr.ph, label %._crit_edge, !llvm.loop !11

.loopexit:                                        ; preds = %._crit_edge, %.preheader39, %13
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %5) #10
  call void @_ZN5RNRgbC1Eddd(ptr noundef nonnull align 8 dereferenceable(24) %5, double noundef 1.000000e+00, double noundef 5.000000e-01, double noundef 0.000000e+00)
  %33 = call noundef i32 @_ZNK7R2Image6HeightEv(ptr noundef nonnull align 8 dereferenceable(24) %6)
  %34 = icmp sgt i32 %33, 0
  br i1 %34, label %.preheader, label %._crit_edge46

.preheader:                                       ; preds = %.loopexit, %._crit_edge44
  %.03445 = phi i32 [ %38, %._crit_edge44 ], [ 0, %.loopexit ]
  %35 = call noundef i32 @_ZNK7R2Image5WidthEv(ptr noundef nonnull align 8 dereferenceable(24) %6)
  %36 = icmp sgt i32 %35, 0
  br i1 %36, label %.lr.ph43, label %._crit_edge44

._crit_edge46:                                    ; preds = %._crit_edge44, %.loopexit
  %37 = call noundef i32 @_ZNK7R2Image5WriteEPKc(ptr noundef nonnull align 8 dereferenceable(24) %6, ptr noundef %1)
  %.not = icmp ne i32 %37, 0
  call void @_ZN7R2ImageD1Ev(ptr noundef nonnull align 8 dereferenceable(24) %6) #10
  call void @_ZdlPvm(ptr noundef nonnull %6, i64 noundef 24) #9
  %. = zext i1 %.not to i32
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %5) #10
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %3) #10
  ret i32 %.

._crit_edge44:                                    ; preds = %44, %.preheader
  %38 = add nuw nsw i32 %.03445, 1
  %39 = call noundef i32 @_ZNK7R2Image6HeightEv(ptr noundef nonnull align 8 dereferenceable(24) %6)
  %40 = icmp slt i32 %38, %39
  br i1 %40, label %.preheader, label %._crit_edge46, !llvm.loop !12

.lr.ph43:                                         ; preds = %.preheader, %44
  %.042 = phi i32 [ %45, %44 ], [ 0, %.preheader ]
  %41 = call noundef double @_ZNK6R2Grid9GridValueEii(ptr noundef nonnull align 8 dereferenceable(208) %0, i32 noundef %.042, i32 noundef %.03445)
  %42 = fcmp une double %41, -3.210000e+02
  br i1 %42, label %44, label %43

43:                                               ; preds = %.lr.ph43
  call void @_ZN7R2Image11SetPixelRGBEiiRK5RNRgb(ptr noundef nonnull align 8 dereferenceable(24) %6, i32 noundef %.042, i32 noundef %.03445, ptr noundef nonnull align 8 dereferenceable(24) %5)
  br label %44

44:                                               ; preds = %.lr.ph43, %43
  %45 = add nuw nsw i32 %.042, 1
  %46 = call noundef i32 @_ZNK7R2Image5WidthEv(ptr noundef nonnull align 8 dereferenceable(24) %6)
  %47 = icmp slt i32 %45, %46
  br i1 %47, label %.lr.ph43, label %._crit_edge44, !llvm.loop !13
}

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

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

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

declare void @_ZN5RNRgbC1Eddd(ptr noundef nonnull align 8 dereferenceable(24), double noundef, double noundef, double noundef) unnamed_addr #7

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { 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 = { 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 #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 = { 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 = { "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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}
!13 = distinct !{!13, !10}


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