; LLVM IR from Wilson-ZheLin/Introduction-to-Digital-Image-Processing :: 9. Thresholding, Roberts, Prewitt, Sobel, and Edge Detection/src/main.ll (Z5SobelP5Image)

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

%struct.Image = type { i32, i32, i32, ptr, [15 x [100 x i8]], i32 }

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

; 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
define dso_local void @_Z5SobelP5Image(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca [9 x i32], align 16
  %7 = alloca float, align 4
  %8 = alloca float, align 4
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #6
  call void @llvm.lifetime.start.p0(i64 36, ptr %6) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #6
  %15 = load ptr, ptr %2, align 8, !tbaa !5
  %16 = call noundef ptr @_Z14CreateNewImageP5ImagePc(ptr noundef %15, ptr noundef @.str.5)
  store ptr %16, ptr %9, align 8, !tbaa !5
  %17 = load ptr, ptr %2, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.Image, ptr %17, i32 0, i32 3
  %19 = load ptr, ptr %18, align 8, !tbaa !9
  store ptr %19, ptr %3, align 8, !tbaa !5
  %20 = load ptr, ptr %9, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.Image, ptr %20, i32 0, i32 3
  %22 = load ptr, ptr %21, align 8, !tbaa !9
  store ptr %22, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  store i32 0, ptr %10, align 4, !tbaa !12
  br label %23

23:                                               ; preds = %167, %1
  %24 = load i32, ptr %10, align 4, !tbaa !12
  %25 = load ptr, ptr %2, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.Image, ptr %25, i32 0, i32 1
  %27 = load i32, ptr %26, align 4, !tbaa !13
  %28 = icmp slt i32 %24, %27
  br i1 %28, label %30, label %29

29:                                               ; preds = %23
  store i32 2, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  br label %170

30:                                               ; preds = %23
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #6
  store i32 0, ptr %12, align 4, !tbaa !12
  br label %31

31:                                               ; preds = %163, %30
  %32 = load i32, ptr %12, align 4, !tbaa !12
  %33 = load ptr, ptr %2, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.Image, ptr %33, i32 0, i32 0
  %35 = load i32, ptr %34, align 8, !tbaa !14
  %36 = icmp slt i32 %32, %35
  br i1 %36, label %38, label %37

37:                                               ; preds = %31
  store i32 5, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #6
  br label %166

38:                                               ; preds = %31
  store i32 0, ptr %5, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #6
  store i32 -1, ptr %13, align 4, !tbaa !12
  br label %39

39:                                               ; preds = %91, %38
  %40 = load i32, ptr %13, align 4, !tbaa !12
  %41 = icmp sle i32 %40, 1
  br i1 %41, label %43, label %42

42:                                               ; preds = %39
  store i32 8, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #6
  br label %94

43:                                               ; preds = %39
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #6
  store i32 -1, ptr %14, align 4, !tbaa !12
  br label %44

44:                                               ; preds = %87, %43
  %45 = load i32, ptr %14, align 4, !tbaa !12
  %46 = icmp sle i32 %45, 1
  br i1 %46, label %48, label %47

47:                                               ; preds = %44
  store i32 11, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #6
  br label %90

48:                                               ; preds = %44
  %49 = load i32, ptr %12, align 4, !tbaa !12
  %50 = load i32, ptr %14, align 4, !tbaa !12
  %51 = add nsw i32 %49, %50
  %52 = load i32, ptr %10, align 4, !tbaa !12
  %53 = load i32, ptr %13, align 4, !tbaa !12
  %54 = add nsw i32 %52, %53
  %55 = load ptr, ptr %2, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.Image, ptr %55, i32 0, i32 0
  %57 = load i32, ptr %56, align 8, !tbaa !14
  %58 = load ptr, ptr %2, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.Image, ptr %58, i32 0, i32 1
  %60 = load i32, ptr %59, align 4, !tbaa !13
  %61 = call noundef i32 @_Z13boundaryCheckiiii(i32 noundef %51, i32 noundef %54, i32 noundef %57, i32 noundef %60)
  %62 = icmp ne i32 %61, 0
  br i1 %62, label %63, label %80

63:                                               ; preds = %48
  %64 = load ptr, ptr %3, align 8, !tbaa !5
  %65 = load ptr, ptr %2, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.Image, ptr %65, i32 0, i32 0
  %67 = load i32, ptr %66, align 8, !tbaa !14
  %68 = load i32, ptr %10, align 4, !tbaa !12
  %69 = load i32, ptr %13, align 4, !tbaa !12
  %70 = add nsw i32 %68, %69
  %71 = mul nsw i32 %67, %70
  %72 = load i32, ptr %12, align 4, !tbaa !12
  %73 = load i32, ptr %14, align 4, !tbaa !12
  %74 = add nsw i32 %72, %73
  %75 = add nsw i32 %71, %74
  %76 = sext i32 %75 to i64
  %77 = getelementptr inbounds i8, ptr %64, i64 %76
  %78 = load i8, ptr %77, align 1, !tbaa !15
  %79 = zext i8 %78 to i32
  br label %81

80:                                               ; preds = %48
  br label %81

81:                                               ; preds = %80, %63
  %82 = phi i32 [ %79, %63 ], [ 0, %80 ]
  %83 = load i32, ptr %5, align 4, !tbaa !12
  %84 = add nsw i32 %83, 1
  store i32 %84, ptr %5, align 4, !tbaa !12
  %85 = sext i32 %83 to i64
  %86 = getelementptr inbounds [9 x i32], ptr %6, i64 0, i64 %85
  store i32 %82, ptr %86, align 4, !tbaa !12
  br label %87

87:                                               ; preds = %81
  %88 = load i32, ptr %14, align 4, !tbaa !12
  %89 = add nsw i32 %88, 1
  store i32 %89, ptr %14, align 4, !tbaa !12
  br label %44, !llvm.loop !16

90:                                               ; preds = %47
  br label %91

91:                                               ; preds = %90
  %92 = load i32, ptr %13, align 4, !tbaa !12
  %93 = add nsw i32 %92, 1
  store i32 %93, ptr %13, align 4, !tbaa !12
  br label %39, !llvm.loop !18

94:                                               ; preds = %42
  %95 = getelementptr inbounds [9 x i32], ptr %6, i64 0, i64 2
  %96 = load i32, ptr %95, align 8, !tbaa !12
  %97 = sitofp i32 %96 to float
  %98 = getelementptr inbounds [9 x i32], ptr %6, i64 0, i64 5
  %99 = load i32, ptr %98, align 4, !tbaa !12
  %100 = sitofp i32 %99 to float
  %101 = call float @llvm.fmuladd.f32(float %100, float 2.000000e+00, float %97)
  %102 = getelementptr inbounds [9 x i32], ptr %6, i64 0, i64 8
  %103 = load i32, ptr %102, align 16, !tbaa !12
  %104 = sitofp i32 %103 to float
  %105 = fadd float %101, %104
  %106 = getelementptr inbounds [9 x i32], ptr %6, i64 0, i64 0
  %107 = load i32, ptr %106, align 16, !tbaa !12
  %108 = sitofp i32 %107 to float
  %109 = fsub float %105, %108
  %110 = getelementptr inbounds [9 x i32], ptr %6, i64 0, i64 3
  %111 = load i32, ptr %110, align 4, !tbaa !12
  %112 = sitofp i32 %111 to float
  %113 = fneg float %112
  %114 = call float @llvm.fmuladd.f32(float %113, float 2.000000e+00, float %109)
  %115 = getelementptr inbounds [9 x i32], ptr %6, i64 0, i64 6
  %116 = load i32, ptr %115, align 8, !tbaa !12
  %117 = sitofp i32 %116 to float
  %118 = fsub float %114, %117
  %119 = call noundef float @_ZSt3absf(float noundef %118)
  store float %119, ptr %7, align 4, !tbaa !19
  %120 = getelementptr inbounds [9 x i32], ptr %6, i64 0, i64 6
  %121 = load i32, ptr %120, align 8, !tbaa !12
  %122 = sitofp i32 %121 to float
  %123 = getelementptr inbounds [9 x i32], ptr %6, i64 0, i64 7
  %124 = load i32, ptr %123, align 4, !tbaa !12
  %125 = sitofp i32 %124 to float
  %126 = call float @llvm.fmuladd.f32(float %125, float 2.000000e+00, float %122)
  %127 = getelementptr inbounds [9 x i32], ptr %6, i64 0, i64 8
  %128 = load i32, ptr %127, align 16, !tbaa !12
  %129 = sitofp i32 %128 to float
  %130 = fadd float %126, %129
  %131 = getelementptr inbounds [9 x i32], ptr %6, i64 0, i64 0
  %132 = load i32, ptr %131, align 16, !tbaa !12
  %133 = sitofp i32 %132 to float
  %134 = fsub float %130, %133
  %135 = getelementptr inbounds [9 x i32], ptr %6, i64 0, i64 1
  %136 = load i32, ptr %135, align 4, !tbaa !12
  %137 = sitofp i32 %136 to float
  %138 = fneg float %137
  %139 = call float @llvm.fmuladd.f32(float %138, float 2.000000e+00, float %134)
  %140 = getelementptr inbounds [9 x i32], ptr %6, i64 0, i64 2
  %141 = load i32, ptr %140, align 8, !tbaa !12
  %142 = sitofp i32 %141 to float
  %143 = fsub float %139, %142
  %144 = call noundef float @_ZSt3absf(float noundef %143)
  store float %144, ptr %8, align 4, !tbaa !19
  %145 = load float, ptr %7, align 4, !tbaa !19
  %146 = call noundef double @_ZSt3powIfiEN9__gnu_cxx9__promoteIDTplcvNS1_IT_Xsr3std12__is_integerIS2_EE7__valueEE6__typeELi0EcvNS1_IT0_Xsr3std12__is_integerIS5_EE7__valueEE6__typeELi0EEXsr3std12__is_integerIS8_EE7__valueEE6__typeES2_S5_(float noundef %145, i32 noundef 2)
  %147 = load float, ptr %8, align 4, !tbaa !19
  %148 = call noundef double @_ZSt3powIfiEN9__gnu_cxx9__promoteIDTplcvNS1_IT_Xsr3std12__is_integerIS2_EE7__valueEE6__typeELi0EcvNS1_IT0_Xsr3std12__is_integerIS5_EE7__valueEE6__typeELi0EEXsr3std12__is_integerIS8_EE7__valueEE6__typeES2_S5_(float noundef %147, i32 noundef 2)
  %149 = fadd double %146, %148
  %150 = call double @sqrt(double noundef %149) #6
  %151 = fptosi double %150 to i32
  %152 = trunc i32 %151 to i8
  %153 = load ptr, ptr %4, align 8, !tbaa !5
  %154 = load ptr, ptr %2, align 8, !tbaa !5
  %155 = getelementptr inbounds %struct.Image, ptr %154, i32 0, i32 0
  %156 = load i32, ptr %155, align 8, !tbaa !14
  %157 = load i32, ptr %10, align 4, !tbaa !12
  %158 = mul nsw i32 %156, %157
  %159 = load i32, ptr %12, align 4, !tbaa !12
  %160 = add nsw i32 %158, %159
  %161 = sext i32 %160 to i64
  %162 = getelementptr inbounds i8, ptr %153, i64 %161
  store i8 %152, ptr %162, align 1, !tbaa !15
  br label %163

163:                                              ; preds = %94
  %164 = load i32, ptr %12, align 4, !tbaa !12
  %165 = add nsw i32 %164, 1
  store i32 %165, ptr %12, align 4, !tbaa !12
  br label %31, !llvm.loop !21

166:                                              ; preds = %37
  br label %167

167:                                              ; preds = %166
  %168 = load i32, ptr %10, align 4, !tbaa !12
  %169 = add nsw i32 %168, 1
  store i32 %169, ptr %10, align 4, !tbaa !12
  br label %23, !llvm.loop !22

170:                                              ; preds = %29
  %171 = load ptr, ptr %9, align 8, !tbaa !5
  %172 = call noundef ptr @_Z9ThresholdP5Image(ptr noundef %171)
  store ptr %172, ptr %9, align 8, !tbaa !5
  %173 = load ptr, ptr %9, align 8, !tbaa !5
  call void @_Z12SavePNMImageP5ImagePc(ptr noundef %173, ptr noundef @.str.7)
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 36, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #6
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_Z14CreateNewImageP5ImagePc(ptr noundef, ptr noundef) #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZSt3powIfiEN9__gnu_cxx9__promoteIDTplcvNS1_IT_Xsr3std12__is_integerIS2_EE7__valueEE6__typeELi0EcvNS1_IT0_Xsr3std12__is_integerIS5_EE7__valueEE6__typeELi0EEXsr3std12__is_integerIS8_EE7__valueEE6__typeES2_S5_(float noundef, i32 noundef) #2

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_Z9ThresholdP5Image(ptr noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z12SavePNMImageP5ImagePc(ptr noundef, ptr noundef) #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z13boundaryCheckiiii(i32 noundef, i32 noundef, i32 noundef, i32 noundef) #3

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_ZSt3absf(float noundef) #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #4

; Function Attrs: nounwind
declare double @sqrt(double noundef) #5

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 = { 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !6, i64 16}
!10 = !{!"_ZTS5Image", !11, i64 0, !11, i64 4, !11, i64 8, !6, i64 16, !7, i64 24, !11, i64 1524}
!11 = !{!"int", !7, i64 0}
!12 = !{!11, !11, i64 0}
!13 = !{!10, !11, i64 4}
!14 = !{!10, !11, i64 0}
!15 = !{!7, !7, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = distinct !{!18, !17}
!19 = !{!20, !20, i64 0}
!20 = !{!"float", !7, i64 0}
!21 = distinct !{!21, !17}
!22 = distinct !{!22, !17}


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

@.str.5 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [10 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local void @_Z5SobelP5Image(ptr noundef %0) local_unnamed_addr #0 {
  %2 = tail call noundef ptr @_Z14CreateNewImageP5ImagePc(ptr noundef %0, ptr noundef nonnull @.str.5)
  %3 = getelementptr inbounds i8, ptr %0, i64 16
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %2, i64 16
  %6 = load ptr, ptr %5, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %0, i64 4
  %8 = load i32, ptr %7, align 4, !tbaa !11
  %9 = icmp sgt i32 %8, 0
  br i1 %9, label %.preheader38.lr.ph, label %._crit_edge45

.preheader38.lr.ph:                               ; preds = %1
  %10 = load i32, ptr %0, align 8, !tbaa !12
  %11 = icmp sgt i32 %10, 0
  br i1 %11, label %.preheader38, label %._crit_edge45

.preheader38:                                     ; preds = %.preheader38.lr.ph, %._crit_edge
  %12 = phi i32 [ %22, %._crit_edge ], [ %8, %.preheader38.lr.ph ]
  %13 = phi i32 [ %23, %._crit_edge ], [ %10, %.preheader38.lr.ph ]
  %.03544 = phi i32 [ %.pre-phi, %._crit_edge ], [ 0, %.preheader38.lr.ph ]
  %14 = icmp sgt i32 %13, 0
  br i1 %14, label %.preheader37.preheader, label %.preheader38.._crit_edge_crit_edge

.preheader38.._crit_edge_crit_edge:               ; preds = %.preheader38
  %.pre61 = add nuw nsw i32 %.03544, 1
  br label %._crit_edge

.preheader37.preheader:                           ; preds = %.preheader38
  %15 = add nsw i32 %.03544, -1
  %16 = add nuw nsw i32 %.03544, 1
  br label %.preheader37

._crit_edge45:                                    ; preds = %._crit_edge, %.preheader38.lr.ph, %1
  %17 = tail call noundef ptr @_Z9ThresholdP5Image(ptr noundef %2)
  tail call void @_Z12SavePNMImageP5ImagePc(ptr noundef %17, ptr noundef nonnull @.str.7)
  ret void

.preheader37:                                     ; preds = %.preheader37.preheader, %111
  %18 = phi i32 [ %146, %111 ], [ %13, %.preheader37.preheader ]
  %.03443 = phi i32 [ %45, %111 ], [ 0, %.preheader37.preheader ]
  %19 = add nsw i32 %.03443, -1
  %20 = load i32, ptr %7, align 4, !tbaa !11
  %21 = tail call noundef i32 @_Z13boundaryCheckiiii(i32 noundef %19, i32 noundef %15, i32 noundef %18, i32 noundef %20)
  %.not = icmp eq i32 %21, 0
  %.pre = load i32, ptr %0, align 8, !tbaa !12
  br i1 %.not, label %32, label %25

._crit_edge.loopexit:                             ; preds = %111
  %.pre60 = load i32, ptr %7, align 4, !tbaa !11
  br label %._crit_edge

._crit_edge:                                      ; preds = %.preheader38.._crit_edge_crit_edge, %._crit_edge.loopexit
  %.pre-phi = phi i32 [ %.pre61, %.preheader38.._crit_edge_crit_edge ], [ %16, %._crit_edge.loopexit ]
  %22 = phi i32 [ %12, %.preheader38.._crit_edge_crit_edge ], [ %.pre60, %._crit_edge.loopexit ]
  %23 = phi i32 [ %13, %.preheader38.._crit_edge_crit_edge ], [ %146, %._crit_edge.loopexit ]
  %24 = icmp slt i32 %.pre-phi, %22
  br i1 %24, label %.preheader38, label %._crit_edge45, !llvm.loop !13

25:                                               ; preds = %.preheader37
  %26 = mul nsw i32 %.pre, %15
  %27 = add nsw i32 %26, %19
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds i8, ptr %4, i64 %28
  %30 = load i8, ptr %29, align 1, !tbaa !16
  %31 = zext i8 %30 to i32
  br label %32

32:                                               ; preds = %.preheader37, %25
  %33 = phi i32 [ %31, %25 ], [ 0, %.preheader37 ]
  %34 = load i32, ptr %7, align 4, !tbaa !11
  %35 = tail call noundef i32 @_Z13boundaryCheckiiii(i32 noundef %.03443, i32 noundef %15, i32 noundef %.pre, i32 noundef %34)
  %.not.1 = icmp eq i32 %35, 0
  %.pre53 = load i32, ptr %0, align 8, !tbaa !12
  br i1 %.not.1, label %43, label %36

36:                                               ; preds = %32
  %37 = mul nsw i32 %.pre53, %15
  %38 = add nsw i32 %37, %.03443
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds i8, ptr %4, i64 %39
  %41 = load i8, ptr %40, align 1, !tbaa !16
  %42 = zext i8 %41 to i32
  br label %43

43:                                               ; preds = %36, %32
  %44 = phi i32 [ %42, %36 ], [ 0, %32 ]
  %45 = add nuw nsw i32 %.03443, 1
  %46 = load i32, ptr %7, align 4, !tbaa !11
  %47 = tail call noundef i32 @_Z13boundaryCheckiiii(i32 noundef %45, i32 noundef %15, i32 noundef %.pre53, i32 noundef %46)
  %.not.2 = icmp eq i32 %47, 0
  %.pre54 = load i32, ptr %0, align 8, !tbaa !12
  br i1 %.not.2, label %.preheader.1, label %48

48:                                               ; preds = %43
  %49 = mul nsw i32 %.pre54, %15
  %50 = add nsw i32 %49, %45
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds i8, ptr %4, i64 %51
  %53 = load i8, ptr %52, align 1, !tbaa !16
  %54 = zext i8 %53 to i32
  br label %.preheader.1

.preheader.1:                                     ; preds = %48, %43
  %55 = phi i32 [ %54, %48 ], [ 0, %43 ]
  %56 = load i32, ptr %7, align 4, !tbaa !11
  %57 = tail call noundef i32 @_Z13boundaryCheckiiii(i32 noundef %19, i32 noundef %.03544, i32 noundef %.pre54, i32 noundef %56)
  %.not.150 = icmp eq i32 %57, 0
  %.pre55 = load i32, ptr %0, align 8, !tbaa !12
  br i1 %.not.150, label %65, label %58

58:                                               ; preds = %.preheader.1
  %59 = mul nsw i32 %.pre55, %.03544
  %60 = add nsw i32 %59, %19
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds i8, ptr %4, i64 %61
  %63 = load i8, ptr %62, align 1, !tbaa !16
  %64 = zext i8 %63 to i32
  br label %65

65:                                               ; preds = %58, %.preheader.1
  %66 = phi i32 [ %64, %58 ], [ 0, %.preheader.1 ]
  %67 = load i32, ptr %7, align 4, !tbaa !11
  %68 = tail call noundef i32 @_Z13boundaryCheckiiii(i32 noundef %.03443, i32 noundef %.03544, i32 noundef %.pre55, i32 noundef %67)
  %.pre56 = load i32, ptr %0, align 8, !tbaa !12
  %69 = load i32, ptr %7, align 4, !tbaa !11
  %70 = tail call noundef i32 @_Z13boundaryCheckiiii(i32 noundef %45, i32 noundef %.03544, i32 noundef %.pre56, i32 noundef %69)
  %.not.2.1 = icmp eq i32 %70, 0
  %.pre57 = load i32, ptr %0, align 8, !tbaa !12
  br i1 %.not.2.1, label %.preheader.2, label %71

71:                                               ; preds = %65
  %72 = mul nsw i32 %.pre57, %.03544
  %73 = add nsw i32 %72, %45
  %74 = sext i32 %73 to i64
  %75 = getelementptr inbounds i8, ptr %4, i64 %74
  %76 = load i8, ptr %75, align 1, !tbaa !16
  %77 = zext i8 %76 to i32
  br label %.preheader.2

.preheader.2:                                     ; preds = %71, %65
  %78 = phi i32 [ %77, %71 ], [ 0, %65 ]
  %79 = load i32, ptr %7, align 4, !tbaa !11
  %80 = tail call noundef i32 @_Z13boundaryCheckiiii(i32 noundef %19, i32 noundef %16, i32 noundef %.pre57, i32 noundef %79)
  %.not.252 = icmp eq i32 %80, 0
  %.pre58 = load i32, ptr %0, align 8, !tbaa !12
  br i1 %.not.252, label %88, label %81

81:                                               ; preds = %.preheader.2
  %82 = mul nsw i32 %.pre58, %16
  %83 = add nsw i32 %82, %19
  %84 = sext i32 %83 to i64
  %85 = getelementptr inbounds i8, ptr %4, i64 %84
  %86 = load i8, ptr %85, align 1, !tbaa !16
  %87 = zext i8 %86 to i32
  br label %88

88:                                               ; preds = %81, %.preheader.2
  %89 = phi i32 [ %87, %81 ], [ 0, %.preheader.2 ]
  %90 = load i32, ptr %7, align 4, !tbaa !11
  %91 = tail call noundef i32 @_Z13boundaryCheckiiii(i32 noundef %.03443, i32 noundef %16, i32 noundef %.pre58, i32 noundef %90)
  %.not.1.2 = icmp eq i32 %91, 0
  %.pre59 = load i32, ptr %0, align 8, !tbaa !12
  br i1 %.not.1.2, label %99, label %92

92:                                               ; preds = %88
  %93 = mul nsw i32 %.pre59, %16
  %94 = add nsw i32 %93, %.03443
  %95 = sext i32 %94 to i64
  %96 = getelementptr inbounds i8, ptr %4, i64 %95
  %97 = load i8, ptr %96, align 1, !tbaa !16
  %98 = zext i8 %97 to i32
  br label %99

99:                                               ; preds = %92, %88
  %100 = phi i32 [ %98, %92 ], [ 0, %88 ]
  %101 = load i32, ptr %7, align 4, !tbaa !11
  %102 = tail call noundef i32 @_Z13boundaryCheckiiii(i32 noundef %45, i32 noundef %16, i32 noundef %.pre59, i32 noundef %101)
  %.not.2.2 = icmp eq i32 %102, 0
  br i1 %.not.2.2, label %111, label %103

103:                                              ; preds = %99
  %104 = load i32, ptr %0, align 8, !tbaa !12
  %105 = mul nsw i32 %104, %16
  %106 = add nsw i32 %105, %45
  %107 = sext i32 %106 to i64
  %108 = getelementptr inbounds i8, ptr %4, i64 %107
  %109 = load i8, ptr %108, align 1, !tbaa !16
  %110 = zext i8 %109 to i32
  br label %111

111:                                              ; preds = %103, %99
  %112 = phi i32 [ %110, %103 ], [ 0, %99 ]
  %113 = uitofp nneg i32 %55 to float
  %114 = uitofp nneg i32 %78 to float
  %115 = tail call float @llvm.fmuladd.f32(float %114, float 2.000000e+00, float %113)
  %116 = uitofp nneg i32 %112 to float
  %117 = fadd float %115, %116
  %118 = uitofp nneg i32 %33 to float
  %119 = fsub float %117, %118
  %120 = uitofp nneg i32 %66 to float
  %121 = fneg float %120
  %122 = tail call float @llvm.fmuladd.f32(float %121, float 2.000000e+00, float %119)
  %123 = uitofp nneg i32 %89 to float
  %124 = fsub float %122, %123
  %125 = tail call noundef float @_ZSt3absf(float noundef %124)
  %126 = uitofp nneg i32 %100 to float
  %127 = tail call float @llvm.fmuladd.f32(float %126, float 2.000000e+00, float %123)
  %128 = fadd float %127, %116
  %129 = fsub float %128, %118
  %130 = uitofp nneg i32 %44 to float
  %131 = fneg float %130
  %132 = tail call float @llvm.fmuladd.f32(float %131, float 2.000000e+00, float %129)
  %133 = fsub float %132, %113
  %134 = tail call noundef float @_ZSt3absf(float noundef %133)
  %135 = tail call noundef double @_ZSt3powIfiEN9__gnu_cxx9__promoteIDTplcvNS1_IT_Xsr3std12__is_integerIS2_EE7__valueEE6__typeELi0EcvNS1_IT0_Xsr3std12__is_integerIS5_EE7__valueEE6__typeELi0EEXsr3std12__is_integerIS8_EE7__valueEE6__typeES2_S5_(float noundef %125, i32 noundef 2)
  %136 = tail call noundef double @_ZSt3powIfiEN9__gnu_cxx9__promoteIDTplcvNS1_IT_Xsr3std12__is_integerIS2_EE7__valueEE6__typeELi0EcvNS1_IT0_Xsr3std12__is_integerIS5_EE7__valueEE6__typeELi0EEXsr3std12__is_integerIS8_EE7__valueEE6__typeES2_S5_(float noundef %134, i32 noundef 2)
  %137 = fadd double %135, %136
  %138 = tail call double @sqrt(double noundef %137) #5
  %139 = fptosi double %138 to i32
  %140 = trunc i32 %139 to i8
  %141 = load i32, ptr %0, align 8, !tbaa !12
  %142 = mul nsw i32 %141, %.03544
  %143 = add nsw i32 %142, %.03443
  %144 = sext i32 %143 to i64
  %145 = getelementptr inbounds i8, ptr %6, i64 %144
  store i8 %140, ptr %145, align 1, !tbaa !16
  %146 = load i32, ptr %0, align 8, !tbaa !12
  %147 = icmp slt i32 %45, %146
  br i1 %147, label %.preheader37, label %._crit_edge.loopexit, !llvm.loop !17
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_Z14CreateNewImageP5ImagePc(ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZSt3powIfiEN9__gnu_cxx9__promoteIDTplcvNS1_IT_Xsr3std12__is_integerIS2_EE7__valueEE6__typeELi0EcvNS1_IT0_Xsr3std12__is_integerIS5_EE7__valueEE6__typeELi0EEXsr3std12__is_integerIS8_EE7__valueEE6__typeES2_S5_(float noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_Z9ThresholdP5Image(ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z12SavePNMImageP5ImagePc(ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z13boundaryCheckiiii(i32 noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_ZSt3absf(float noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #3

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @sqrt(double noundef) local_unnamed_addr #4

attributes #0 = { 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 #1 = { 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 #2 = { 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 nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { mustprogress nofree nounwind willreturn memory(write) "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, !10, i64 16}
!6 = !{!"_ZTS5Image", !7, i64 0, !7, i64 4, !7, i64 8, !10, i64 16, !8, i64 24, !7, i64 1524}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !7, i64 4}
!12 = !{!6, !7, i64 0}
!13 = distinct !{!13, !14, !15}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{!"llvm.loop.unswitch.partial.disable"}
!16 = !{!8, !8, i64 0}
!17 = distinct !{!17, !14}


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