; LLVM IR from Wilson-ZheLin/Introduction-to-Digital-Image-Processing :: 1. Average Filter and Median Filter/src/main.ll (Z11MedianImageP5Image)

; 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.4 = external hidden unnamed_addr constant [24 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 noundef ptr @_Z11MedianImageP5Image(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca [9 x i8], align 1
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %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
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #2
  call void @llvm.lifetime.start.p0(i64 9, ptr %5) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #2
  %17 = load ptr, ptr %2, align 8, !tbaa !5
  %18 = call noundef ptr @_Z14CreateNewImageP5ImagePc(ptr noundef %17, ptr noundef @.str.4)
  store ptr %18, ptr %6, align 8, !tbaa !5
  %19 = load ptr, ptr %2, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.Image, ptr %19, i32 0, i32 3
  %21 = load ptr, ptr %20, align 8, !tbaa !9
  store ptr %21, ptr %3, align 8, !tbaa !5
  %22 = load ptr, ptr %6, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.Image, ptr %22, i32 0, i32 3
  %24 = load ptr, ptr %23, align 8, !tbaa !9
  store ptr %24, ptr %4, align 8, !tbaa !5
  %25 = load ptr, ptr %2, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.Image, ptr %25, i32 0, i32 2
  %27 = load i32, ptr %26, align 8, !tbaa !12
  %28 = icmp eq i32 %27, 1
  br i1 %28, label %29, label %37

29:                                               ; preds = %1
  %30 = load ptr, ptr %2, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.Image, ptr %30, i32 0, i32 0
  %32 = load i32, ptr %31, align 8, !tbaa !13
  %33 = load ptr, ptr %2, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.Image, ptr %33, i32 0, i32 1
  %35 = load i32, ptr %34, align 4, !tbaa !14
  %36 = mul nsw i32 %32, %35
  store i32 %36, ptr %7, align 4, !tbaa !15
  br label %52

37:                                               ; preds = %1
  %38 = load ptr, ptr %2, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.Image, ptr %38, i32 0, i32 2
  %40 = load i32, ptr %39, align 8, !tbaa !12
  %41 = icmp eq i32 %40, 2
  br i1 %41, label %42, label %51

42:                                               ; preds = %37
  %43 = load ptr, ptr %2, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.Image, ptr %43, i32 0, i32 0
  %45 = load i32, ptr %44, align 8, !tbaa !13
  %46 = load ptr, ptr %2, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.Image, ptr %46, i32 0, i32 1
  %48 = load i32, ptr %47, align 4, !tbaa !14
  %49 = mul nsw i32 %45, %48
  %50 = mul nsw i32 %49, 3
  store i32 %50, ptr %7, align 4, !tbaa !15
  br label %51

51:                                               ; preds = %42, %37
  br label %52

52:                                               ; preds = %51, %29
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #2
  store i32 1, ptr %8, align 4, !tbaa !15
  br label %53

53:                                               ; preds = %170, %52
  %54 = load i32, ptr %8, align 4, !tbaa !15
  %55 = load ptr, ptr %2, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.Image, ptr %55, i32 0, i32 1
  %57 = load i32, ptr %56, align 4, !tbaa !14
  %58 = sub nsw i32 %57, 1
  %59 = icmp slt i32 %54, %58
  br i1 %59, label %61, label %60

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

61:                                               ; preds = %53
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #2
  store i32 1, ptr %10, align 4, !tbaa !15
  br label %62

62:                                               ; preds = %166, %61
  %63 = load i32, ptr %10, align 4, !tbaa !15
  %64 = load ptr, ptr %2, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.Image, ptr %64, i32 0, i32 0
  %66 = load i32, ptr %65, align 8, !tbaa !13
  %67 = sub nsw i32 %66, 1
  %68 = icmp slt i32 %63, %67
  br i1 %68, label %70, label %69

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

70:                                               ; preds = %62
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #2
  store i32 0, ptr %11, align 4, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #2
  store i32 -1, ptr %12, align 4, !tbaa !15
  br label %71

71:                                               ; preds = %104, %70
  %72 = load i32, ptr %12, align 4, !tbaa !15
  %73 = icmp sle i32 %72, 1
  br i1 %73, label %75, label %74

74:                                               ; preds = %71
  store i32 8, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #2
  br label %107

75:                                               ; preds = %71
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #2
  store i32 -1, ptr %13, align 4, !tbaa !15
  br label %76

76:                                               ; preds = %100, %75
  %77 = load i32, ptr %13, align 4, !tbaa !15
  %78 = icmp sle i32 %77, 1
  br i1 %78, label %80, label %79

79:                                               ; preds = %76
  store i32 11, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #2
  br label %103

80:                                               ; preds = %76
  %81 = load ptr, ptr %3, align 8, !tbaa !5
  %82 = load ptr, ptr %2, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.Image, ptr %82, i32 0, i32 0
  %84 = load i32, ptr %83, align 8, !tbaa !13
  %85 = load i32, ptr %8, align 4, !tbaa !15
  %86 = load i32, ptr %12, align 4, !tbaa !15
  %87 = add nsw i32 %85, %86
  %88 = mul nsw i32 %84, %87
  %89 = load i32, ptr %10, align 4, !tbaa !15
  %90 = load i32, ptr %13, align 4, !tbaa !15
  %91 = add nsw i32 %89, %90
  %92 = add nsw i32 %88, %91
  %93 = sext i32 %92 to i64
  %94 = getelementptr inbounds i8, ptr %81, i64 %93
  %95 = load i8, ptr %94, align 1, !tbaa !16
  %96 = load i32, ptr %11, align 4, !tbaa !15
  %97 = add nsw i32 %96, 1
  store i32 %97, ptr %11, align 4, !tbaa !15
  %98 = sext i32 %96 to i64
  %99 = getelementptr inbounds [9 x i8], ptr %5, i64 0, i64 %98
  store i8 %95, ptr %99, align 1, !tbaa !16
  br label %100

100:                                              ; preds = %80
  %101 = load i32, ptr %13, align 4, !tbaa !15
  %102 = add nsw i32 %101, 1
  store i32 %102, ptr %13, align 4, !tbaa !15
  br label %76, !llvm.loop !17

103:                                              ; preds = %79
  br label %104

104:                                              ; preds = %103
  %105 = load i32, ptr %12, align 4, !tbaa !15
  %106 = add nsw i32 %105, 1
  store i32 %106, ptr %12, align 4, !tbaa !15
  br label %71, !llvm.loop !19

107:                                              ; preds = %74
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #2
  store i32 1, ptr %14, align 4, !tbaa !15
  br label %108

108:                                              ; preds = %150, %107
  %109 = load i32, ptr %14, align 4, !tbaa !15
  %110 = icmp slt i32 %109, 9
  br i1 %110, label %112, label %111

111:                                              ; preds = %108
  store i32 14, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #2
  br label %153

112:                                              ; preds = %108
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #2
  %113 = load i32, ptr %14, align 4, !tbaa !15
  %114 = sext i32 %113 to i64
  %115 = getelementptr inbounds [9 x i8], ptr %5, i64 0, i64 %114
  %116 = load i8, ptr %115, align 1, !tbaa !16
  %117 = zext i8 %116 to i32
  store i32 %117, ptr %15, align 4, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #2
  %118 = load i32, ptr %14, align 4, !tbaa !15
  store i32 %118, ptr %16, align 4, !tbaa !15
  br label %119

119:                                              ; preds = %133, %112
  %120 = load i32, ptr %16, align 4, !tbaa !15
  %121 = icmp sge i32 %120, 1
  br i1 %121, label %122, label %131

122:                                              ; preds = %119
  %123 = load i32, ptr %16, align 4, !tbaa !15
  %124 = sub nsw i32 %123, 1
  %125 = sext i32 %124 to i64
  %126 = getelementptr inbounds [9 x i8], ptr %5, i64 0, i64 %125
  %127 = load i8, ptr %126, align 1, !tbaa !16
  %128 = zext i8 %127 to i32
  %129 = load i32, ptr %15, align 4, !tbaa !15
  %130 = icmp sgt i32 %128, %129
  br label %131

131:                                              ; preds = %122, %119
  %132 = phi i1 [ false, %119 ], [ %130, %122 ]
  br i1 %132, label %133, label %144

133:                                              ; preds = %131
  %134 = load i32, ptr %16, align 4, !tbaa !15
  %135 = sub nsw i32 %134, 1
  %136 = sext i32 %135 to i64
  %137 = getelementptr inbounds [9 x i8], ptr %5, i64 0, i64 %136
  %138 = load i8, ptr %137, align 1, !tbaa !16
  %139 = load i32, ptr %16, align 4, !tbaa !15
  %140 = sext i32 %139 to i64
  %141 = getelementptr inbounds [9 x i8], ptr %5, i64 0, i64 %140
  store i8 %138, ptr %141, align 1, !tbaa !16
  %142 = load i32, ptr %16, align 4, !tbaa !15
  %143 = add nsw i32 %142, -1
  store i32 %143, ptr %16, align 4, !tbaa !15
  br label %119, !llvm.loop !20

144:                                              ; preds = %131
  %145 = load i32, ptr %15, align 4, !tbaa !15
  %146 = trunc i32 %145 to i8
  %147 = load i32, ptr %16, align 4, !tbaa !15
  %148 = sext i32 %147 to i64
  %149 = getelementptr inbounds [9 x i8], ptr %5, i64 0, i64 %148
  store i8 %146, ptr %149, align 1, !tbaa !16
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #2
  br label %150

150:                                              ; preds = %144
  %151 = load i32, ptr %14, align 4, !tbaa !15
  %152 = add nsw i32 %151, 1
  store i32 %152, ptr %14, align 4, !tbaa !15
  br label %108, !llvm.loop !21

153:                                              ; preds = %111
  %154 = getelementptr inbounds [9 x i8], ptr %5, i64 0, i64 4
  %155 = load i8, ptr %154, align 1, !tbaa !16
  %156 = load ptr, ptr %4, align 8, !tbaa !5
  %157 = load ptr, ptr %2, align 8, !tbaa !5
  %158 = getelementptr inbounds %struct.Image, ptr %157, i32 0, i32 0
  %159 = load i32, ptr %158, align 8, !tbaa !13
  %160 = load i32, ptr %8, align 4, !tbaa !15
  %161 = mul nsw i32 %159, %160
  %162 = load i32, ptr %10, align 4, !tbaa !15
  %163 = add nsw i32 %161, %162
  %164 = sext i32 %163 to i64
  %165 = getelementptr inbounds i8, ptr %156, i64 %164
  store i8 %155, ptr %165, align 1, !tbaa !16
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #2
  br label %166

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

169:                                              ; preds = %69
  br label %170

170:                                              ; preds = %169
  %171 = load i32, ptr %8, align 4, !tbaa !15
  %172 = add nsw i32 %171, 1
  store i32 %172, ptr %8, align 4, !tbaa !15
  br label %53, !llvm.loop !23

173:                                              ; preds = %60
  %174 = load ptr, ptr %6, align 8, !tbaa !5
  store i32 1, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 9, ptr %5) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #2
  ret ptr %174
}

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

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 = { 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 = !{!10, !11, i64 8}
!13 = !{!10, !11, i64 0}
!14 = !{!10, !11, i64 4}
!15 = !{!11, !11, i64 0}
!16 = !{!7, !7, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = distinct !{!19, !18}
!20 = distinct !{!20, !18}
!21 = distinct !{!21, !18}
!22 = distinct !{!22, !18}
!23 = distinct !{!23, !18}


; 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.4 = external hidden unnamed_addr constant [24 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

; 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
define dso_local noundef ptr @_Z11MedianImageP5Image(ptr noundef %0) local_unnamed_addr #1 {
  %.sroa.0 = alloca i8, align 1
  %.sroa.18 = alloca i8, align 1
  %.sroa.42 = alloca i8, align 1
  %.sroa.63 = alloca i8, align 1
  %.sroa.82 = alloca i8, align 1
  %.sroa.98 = alloca i8, align 1
  %.sroa.111 = alloca i8, align 1
  %.sroa.121 = alloca i8, align 1
  %.sroa.128 = alloca i8, align 1
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %.sroa.0)
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %.sroa.18)
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %.sroa.42)
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %.sroa.63)
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %.sroa.82)
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %.sroa.98)
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %.sroa.111)
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %.sroa.121)
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %.sroa.128)
  %2 = tail call noundef ptr @_Z14CreateNewImageP5ImagePc(ptr noundef %0, ptr noundef nonnull @.str.4)
  %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, 2
  br i1 %9, label %.preheader51.lr.ph, label %._crit_edge60

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

.preheader51:                                     ; preds = %.preheader51.lr.ph, %._crit_edge
  %12 = phi i32 [ %62, %._crit_edge ], [ %8, %.preheader51.lr.ph ]
  %13 = phi i32 [ %63, %._crit_edge ], [ %10, %.preheader51.lr.ph ]
  %indvars.iv = phi i64 [ %indvars.iv.next.pre-phi, %._crit_edge ], [ 1, %.preheader51.lr.ph ]
  %14 = icmp sgt i32 %13, 2
  br i1 %14, label %.preheader50.preheader, label %.preheader51.._crit_edge_crit_edge

.preheader51.._crit_edge_crit_edge:               ; preds = %.preheader51
  %.pre79 = add nuw nsw i64 %indvars.iv, 1
  br label %._crit_edge

.preheader50.preheader:                           ; preds = %.preheader51
  %15 = trunc i64 %indvars.iv to i32
  %16 = add i32 %15, -1
  %17 = trunc i64 %indvars.iv to i32
  %18 = add nuw nsw i64 %indvars.iv, 1
  %19 = trunc i64 %18 to i32
  %20 = trunc nuw nsw i64 %indvars.iv to i32
  br label %.preheader50

._crit_edge60:                                    ; preds = %._crit_edge, %.preheader51.lr.ph, %1
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %.sroa.0)
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %.sroa.18)
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %.sroa.42)
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %.sroa.63)
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %.sroa.82)
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %.sroa.98)
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %.sroa.111)
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %.sroa.121)
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %.sroa.128)
  ret ptr %2

.preheader50:                                     ; preds = %.preheader50.preheader, %.critedge.7
  %21 = phi i32 [ %143, %.critedge.7 ], [ %13, %.preheader50.preheader ]
  %.04658 = phi i32 [ %142, %.critedge.7 ], [ 1, %.preheader50.preheader ]
  %22 = mul i32 %16, %21
  %23 = add i32 %22, %.04658
  %24 = add i32 %23, -1
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds i8, ptr %4, i64 %25
  %27 = load i8, ptr %26, align 1, !tbaa !13
  store i8 %27, ptr %.sroa.0, align 1, !tbaa !13
  %28 = sext i32 %23 to i64
  %29 = getelementptr inbounds i8, ptr %4, i64 %28
  %30 = load i8, ptr %29, align 1, !tbaa !13
  store i8 %30, ptr %.sroa.18, align 1, !tbaa !13
  %31 = add i32 %23, 1
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds i8, ptr %4, i64 %32
  %34 = load i8, ptr %33, align 1, !tbaa !13
  store i8 %34, ptr %.sroa.42, align 1, !tbaa !13
  %35 = mul i32 %21, %17
  %36 = add i32 %35, %.04658
  %37 = add i32 %36, -1
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds i8, ptr %4, i64 %38
  %40 = load i8, ptr %39, align 1, !tbaa !13
  store i8 %40, ptr %.sroa.63, align 1, !tbaa !13
  %41 = sext i32 %36 to i64
  %42 = getelementptr inbounds i8, ptr %4, i64 %41
  %43 = load i8, ptr %42, align 1, !tbaa !13
  store i8 %43, ptr %.sroa.82, align 1, !tbaa !13
  %44 = add i32 %36, 1
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds i8, ptr %4, i64 %45
  %47 = load i8, ptr %46, align 1, !tbaa !13
  store i8 %47, ptr %.sroa.98, align 1, !tbaa !13
  %48 = mul i32 %21, %19
  %49 = add i32 %48, %.04658
  %50 = add i32 %49, -1
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds i8, ptr %4, i64 %51
  %53 = load i8, ptr %52, align 1, !tbaa !13
  store i8 %53, ptr %.sroa.111, align 1, !tbaa !13
  %54 = sext i32 %49 to i64
  %55 = getelementptr inbounds i8, ptr %4, i64 %54
  %56 = load i8, ptr %55, align 1, !tbaa !13
  store i8 %56, ptr %.sroa.121, align 1, !tbaa !13
  %57 = add i32 %49, 1
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds i8, ptr %4, i64 %58
  %60 = load i8, ptr %59, align 1, !tbaa !13
  store i8 %60, ptr %.sroa.128, align 1, !tbaa !13
  %61 = icmp ugt i8 %27, %30
  br i1 %61, label %67, label %.critedge

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

._crit_edge:                                      ; preds = %.preheader51.._crit_edge_crit_edge, %._crit_edge.loopexit
  %indvars.iv.next.pre-phi = phi i64 [ %.pre79, %.preheader51.._crit_edge_crit_edge ], [ %18, %._crit_edge.loopexit ]
  %62 = phi i32 [ %12, %.preheader51.._crit_edge_crit_edge ], [ %.pre, %._crit_edge.loopexit ]
  %63 = phi i32 [ %13, %.preheader51.._crit_edge_crit_edge ], [ %143, %._crit_edge.loopexit ]
  %64 = add nsw i32 %62, -1
  %65 = sext i32 %64 to i64
  %66 = icmp slt i64 %indvars.iv.next.pre-phi, %65
  br i1 %66, label %.preheader51, label %._crit_edge60, !llvm.loop !14

67:                                               ; preds = %.preheader50
  store i8 %27, ptr %.sroa.18, align 1, !tbaa !13
  br label %.critedge

.critedge:                                        ; preds = %67, %.preheader50
  %.0.lcssa.sroa.phi = phi ptr [ %.sroa.0, %67 ], [ %.sroa.18, %.preheader50 ]
  store i8 %30, ptr %.0.lcssa.sroa.phi, align 1, !tbaa !13
  %.sroa.18.0..sroa.18.1.128 = load i8, ptr %.sroa.18, align 1, !tbaa !13
  %68 = icmp ugt i8 %.sroa.18.0..sroa.18.1.128, %34
  br i1 %68, label %69, label %.critedge.1

69:                                               ; preds = %.critedge
  store i8 %.sroa.18.0..sroa.18.1.128, ptr %.sroa.42, align 1, !tbaa !13
  %.sroa.0.0..sroa.0.0.122 = load i8, ptr %.sroa.0, align 1, !tbaa !13
  %70 = icmp ugt i8 %.sroa.0.0..sroa.0.0.122, %34
  br i1 %70, label %71, label %.critedge.1

71:                                               ; preds = %69
  store i8 %.sroa.0.0..sroa.0.0.122, ptr %.sroa.18, align 1, !tbaa !13
  br label %.critedge.1

.critedge.1:                                      ; preds = %71, %69, %.critedge
  %.0.lcssa.1.sroa.phi = phi ptr [ %.sroa.42, %.critedge ], [ %.sroa.18, %69 ], [ %.sroa.0, %71 ]
  store i8 %34, ptr %.0.lcssa.1.sroa.phi, align 1, !tbaa !13
  %.sroa.63.0..sroa.63.3.138 = load i8, ptr %.sroa.63, align 1, !tbaa !13
  %.sroa.42.0..sroa.42.2.133 = load i8, ptr %.sroa.42, align 1, !tbaa !13
  %72 = icmp ugt i8 %.sroa.42.0..sroa.42.2.133, %.sroa.63.0..sroa.63.3.138
  br i1 %72, label %73, label %.critedge.2

73:                                               ; preds = %.critedge.1
  store i8 %.sroa.42.0..sroa.42.2.133, ptr %.sroa.63, align 1, !tbaa !13
  %.sroa.18.0..sroa.18.1.127 = load i8, ptr %.sroa.18, align 1, !tbaa !13
  %74 = icmp ugt i8 %.sroa.18.0..sroa.18.1.127, %.sroa.63.0..sroa.63.3.138
  br i1 %74, label %75, label %.critedge.2

75:                                               ; preds = %73
  store i8 %.sroa.18.0..sroa.18.1.127, ptr %.sroa.42, align 1, !tbaa !13
  %.sroa.0.0..sroa.0.0.121 = load i8, ptr %.sroa.0, align 1, !tbaa !13
  %76 = icmp ugt i8 %.sroa.0.0..sroa.0.0.121, %.sroa.63.0..sroa.63.3.138
  br i1 %76, label %77, label %.critedge.2

77:                                               ; preds = %75
  store i8 %.sroa.0.0..sroa.0.0.121, ptr %.sroa.18, align 1, !tbaa !13
  br label %.critedge.2

.critedge.2:                                      ; preds = %77, %75, %73, %.critedge.1
  %.0.lcssa.2.sroa.phi = phi ptr [ %.sroa.63, %.critedge.1 ], [ %.sroa.42, %73 ], [ %.sroa.18, %75 ], [ %.sroa.0, %77 ]
  store i8 %.sroa.63.0..sroa.63.3.138, ptr %.0.lcssa.2.sroa.phi, align 1, !tbaa !13
  %.sroa.63.0..sroa.63.3.137 = load i8, ptr %.sroa.63, align 1, !tbaa !13
  %78 = icmp ugt i8 %.sroa.63.0..sroa.63.3.137, %43
  br i1 %78, label %79, label %.critedge.3

79:                                               ; preds = %.critedge.2
  store i8 %.sroa.63.0..sroa.63.3.137, ptr %.sroa.82, align 1, !tbaa !13
  %.sroa.42.0..sroa.42.2.132 = load i8, ptr %.sroa.42, align 1, !tbaa !13
  %80 = icmp ugt i8 %.sroa.42.0..sroa.42.2.132, %43
  br i1 %80, label %81, label %.critedge.3

81:                                               ; preds = %79
  store i8 %.sroa.42.0..sroa.42.2.132, ptr %.sroa.63, align 1, !tbaa !13
  %.sroa.18.0..sroa.18.1.126 = load i8, ptr %.sroa.18, align 1, !tbaa !13
  %82 = icmp ugt i8 %.sroa.18.0..sroa.18.1.126, %43
  br i1 %82, label %83, label %.critedge.3

83:                                               ; preds = %81
  store i8 %.sroa.18.0..sroa.18.1.126, ptr %.sroa.42, align 1, !tbaa !13
  %.sroa.0.0..sroa.0.0.120 = load i8, ptr %.sroa.0, align 1, !tbaa !13
  %84 = icmp ugt i8 %.sroa.0.0..sroa.0.0.120, %43
  br i1 %84, label %85, label %.critedge.3

85:                                               ; preds = %83
  store i8 %.sroa.0.0..sroa.0.0.120, ptr %.sroa.18, align 1, !tbaa !13
  br label %.critedge.3

.critedge.3:                                      ; preds = %85, %83, %81, %79, %.critedge.2
  %.0.lcssa.3.sroa.phi = phi ptr [ %.sroa.82, %.critedge.2 ], [ %.sroa.63, %79 ], [ %.sroa.42, %81 ], [ %.sroa.18, %83 ], [ %.sroa.0, %85 ]
  store i8 %43, ptr %.0.lcssa.3.sroa.phi, align 1, !tbaa !13
  %.sroa.98.0..sroa.98.5.145 = load i8, ptr %.sroa.98, align 1, !tbaa !13
  %.sroa.82.0..sroa.82.4.139 = load i8, ptr %.sroa.82, align 1, !tbaa !13
  %86 = icmp ugt i8 %.sroa.82.0..sroa.82.4.139, %.sroa.98.0..sroa.98.5.145
  br i1 %86, label %87, label %.critedge.4

87:                                               ; preds = %.critedge.3
  store i8 %.sroa.82.0..sroa.82.4.139, ptr %.sroa.98, align 1, !tbaa !13
  %.sroa.63.0..sroa.63.3.136 = load i8, ptr %.sroa.63, align 1, !tbaa !13
  %88 = icmp ugt i8 %.sroa.63.0..sroa.63.3.136, %.sroa.98.0..sroa.98.5.145
  br i1 %88, label %89, label %.critedge.4

89:                                               ; preds = %87
  store i8 %.sroa.63.0..sroa.63.3.136, ptr %.sroa.82, align 1, !tbaa !13
  %.sroa.42.0..sroa.42.2.131 = load i8, ptr %.sroa.42, align 1, !tbaa !13
  %90 = icmp ugt i8 %.sroa.42.0..sroa.42.2.131, %.sroa.98.0..sroa.98.5.145
  br i1 %90, label %91, label %.critedge.4

91:                                               ; preds = %89
  store i8 %.sroa.42.0..sroa.42.2.131, ptr %.sroa.63, align 1, !tbaa !13
  %.sroa.18.0..sroa.18.1.125 = load i8, ptr %.sroa.18, align 1, !tbaa !13
  %92 = icmp ugt i8 %.sroa.18.0..sroa.18.1.125, %.sroa.98.0..sroa.98.5.145
  br i1 %92, label %93, label %.critedge.4

93:                                               ; preds = %91
  store i8 %.sroa.18.0..sroa.18.1.125, ptr %.sroa.42, align 1, !tbaa !13
  %.sroa.0.0..sroa.0.0.119 = load i8, ptr %.sroa.0, align 1, !tbaa !13
  %94 = icmp ugt i8 %.sroa.0.0..sroa.0.0.119, %.sroa.98.0..sroa.98.5.145
  br i1 %94, label %95, label %.critedge.4

95:                                               ; preds = %93
  store i8 %.sroa.0.0..sroa.0.0.119, ptr %.sroa.18, align 1, !tbaa !13
  br label %.critedge.4

.critedge.4:                                      ; preds = %95, %93, %91, %89, %87, %.critedge.3
  %.0.lcssa.4.sroa.phi = phi ptr [ %.sroa.98, %.critedge.3 ], [ %.sroa.82, %87 ], [ %.sroa.63, %89 ], [ %.sroa.42, %91 ], [ %.sroa.18, %93 ], [ %.sroa.0, %95 ]
  store i8 %.sroa.98.0..sroa.98.5.145, ptr %.0.lcssa.4.sroa.phi, align 1, !tbaa !13
  %.sroa.111.0..sroa.111.6.147 = load i8, ptr %.sroa.111, align 1, !tbaa !13
  %.sroa.98.0..sroa.98.5.144 = load i8, ptr %.sroa.98, align 1, !tbaa !13
  %96 = icmp ugt i8 %.sroa.98.0..sroa.98.5.144, %.sroa.111.0..sroa.111.6.147
  br i1 %96, label %97, label %.critedge.5

97:                                               ; preds = %.critedge.4
  store i8 %.sroa.98.0..sroa.98.5.144, ptr %.sroa.111, align 1, !tbaa !13
  %.sroa.82.0..sroa.82.4.140 = load i8, ptr %.sroa.82, align 1, !tbaa !13
  %98 = icmp ugt i8 %.sroa.82.0..sroa.82.4.140, %.sroa.111.0..sroa.111.6.147
  br i1 %98, label %99, label %.critedge.5

99:                                               ; preds = %97
  store i8 %.sroa.82.0..sroa.82.4.140, ptr %.sroa.98, align 1, !tbaa !13
  %.sroa.63.0..sroa.63.3.135 = load i8, ptr %.sroa.63, align 1, !tbaa !13
  %100 = icmp ugt i8 %.sroa.63.0..sroa.63.3.135, %.sroa.111.0..sroa.111.6.147
  br i1 %100, label %101, label %.critedge.5

101:                                              ; preds = %99
  store i8 %.sroa.63.0..sroa.63.3.135, ptr %.sroa.82, align 1, !tbaa !13
  %.sroa.42.0..sroa.42.2.130 = load i8, ptr %.sroa.42, align 1, !tbaa !13
  %102 = icmp ugt i8 %.sroa.42.0..sroa.42.2.130, %.sroa.111.0..sroa.111.6.147
  br i1 %102, label %103, label %.critedge.5

103:                                              ; preds = %101
  store i8 %.sroa.42.0..sroa.42.2.130, ptr %.sroa.63, align 1, !tbaa !13
  %.sroa.18.0..sroa.18.1.124 = load i8, ptr %.sroa.18, align 1, !tbaa !13
  %104 = icmp ugt i8 %.sroa.18.0..sroa.18.1.124, %.sroa.111.0..sroa.111.6.147
  br i1 %104, label %105, label %.critedge.5

105:                                              ; preds = %103
  store i8 %.sroa.18.0..sroa.18.1.124, ptr %.sroa.42, align 1, !tbaa !13
  %.sroa.0.0..sroa.0.0.118 = load i8, ptr %.sroa.0, align 1, !tbaa !13
  %106 = icmp ugt i8 %.sroa.0.0..sroa.0.0.118, %.sroa.111.0..sroa.111.6.147
  br i1 %106, label %107, label %.critedge.5

107:                                              ; preds = %105
  store i8 %.sroa.0.0..sroa.0.0.118, ptr %.sroa.18, align 1, !tbaa !13
  br label %.critedge.5

.critedge.5:                                      ; preds = %107, %105, %103, %101, %99, %97, %.critedge.4
  %.0.lcssa.5.sroa.phi = phi ptr [ %.sroa.111, %.critedge.4 ], [ %.sroa.98, %97 ], [ %.sroa.82, %99 ], [ %.sroa.63, %101 ], [ %.sroa.42, %103 ], [ %.sroa.18, %105 ], [ %.sroa.0, %107 ]
  store i8 %.sroa.111.0..sroa.111.6.147, ptr %.0.lcssa.5.sroa.phi, align 1, !tbaa !13
  %.sroa.121.0..sroa.121.7.148 = load i8, ptr %.sroa.121, align 1, !tbaa !13
  %.sroa.111.0..sroa.111.6.146 = load i8, ptr %.sroa.111, align 1, !tbaa !13
  %108 = icmp ugt i8 %.sroa.111.0..sroa.111.6.146, %.sroa.121.0..sroa.121.7.148
  br i1 %108, label %109, label %.critedge.6

109:                                              ; preds = %.critedge.5
  store i8 %.sroa.111.0..sroa.111.6.146, ptr %.sroa.121, align 1, !tbaa !13
  %.sroa.98.0..sroa.98.5.143 = load i8, ptr %.sroa.98, align 1, !tbaa !13
  %110 = icmp ugt i8 %.sroa.98.0..sroa.98.5.143, %.sroa.121.0..sroa.121.7.148
  br i1 %110, label %111, label %.critedge.6

111:                                              ; preds = %109
  store i8 %.sroa.98.0..sroa.98.5.143, ptr %.sroa.111, align 1, !tbaa !13
  %.sroa.82.0..sroa.82.4.141 = load i8, ptr %.sroa.82, align 1, !tbaa !13
  %112 = icmp ugt i8 %.sroa.82.0..sroa.82.4.141, %.sroa.121.0..sroa.121.7.148
  br i1 %112, label %113, label %.critedge.6

113:                                              ; preds = %111
  store i8 %.sroa.82.0..sroa.82.4.141, ptr %.sroa.98, align 1, !tbaa !13
  %.sroa.63.0..sroa.63.3.134 = load i8, ptr %.sroa.63, align 1, !tbaa !13
  %114 = icmp ugt i8 %.sroa.63.0..sroa.63.3.134, %.sroa.121.0..sroa.121.7.148
  br i1 %114, label %115, label %.critedge.6

115:                                              ; preds = %113
  store i8 %.sroa.63.0..sroa.63.3.134, ptr %.sroa.82, align 1, !tbaa !13
  %.sroa.42.0..sroa.42.2.129 = load i8, ptr %.sroa.42, align 1, !tbaa !13
  %116 = icmp ugt i8 %.sroa.42.0..sroa.42.2.129, %.sroa.121.0..sroa.121.7.148
  br i1 %116, label %117, label %.critedge.6

117:                                              ; preds = %115
  store i8 %.sroa.42.0..sroa.42.2.129, ptr %.sroa.63, align 1, !tbaa !13
  %.sroa.18.0..sroa.18.1.123 = load i8, ptr %.sroa.18, align 1, !tbaa !13
  %118 = icmp ugt i8 %.sroa.18.0..sroa.18.1.123, %.sroa.121.0..sroa.121.7.148
  br i1 %118, label %119, label %.critedge.6

119:                                              ; preds = %117
  store i8 %.sroa.18.0..sroa.18.1.123, ptr %.sroa.42, align 1, !tbaa !13
  %.sroa.0.0..sroa.0.0.117 = load i8, ptr %.sroa.0, align 1, !tbaa !13
  %120 = icmp ugt i8 %.sroa.0.0..sroa.0.0.117, %.sroa.121.0..sroa.121.7.148
  br i1 %120, label %121, label %.critedge.6

121:                                              ; preds = %119
  store i8 %.sroa.0.0..sroa.0.0.117, ptr %.sroa.18, align 1, !tbaa !13
  br label %.critedge.6

.critedge.6:                                      ; preds = %121, %119, %117, %115, %113, %111, %109, %.critedge.5
  %.0.lcssa.6.sroa.phi = phi ptr [ %.sroa.121, %.critedge.5 ], [ %.sroa.111, %109 ], [ %.sroa.98, %111 ], [ %.sroa.82, %113 ], [ %.sroa.63, %115 ], [ %.sroa.42, %117 ], [ %.sroa.18, %119 ], [ %.sroa.0, %121 ]
  store i8 %.sroa.121.0..sroa.121.7.148, ptr %.0.lcssa.6.sroa.phi, align 1, !tbaa !13
  %.sroa.121.0..sroa.121.7. = load i8, ptr %.sroa.121, align 1, !tbaa !13
  %122 = icmp ugt i8 %.sroa.121.0..sroa.121.7., %60
  br i1 %122, label %123, label %.critedge.7

123:                                              ; preds = %.critedge.6
  store i8 %.sroa.121.0..sroa.121.7., ptr %.sroa.128, align 1, !tbaa !13
  %.sroa.111.0..sroa.111.6. = load i8, ptr %.sroa.111, align 1, !tbaa !13
  %124 = icmp ugt i8 %.sroa.111.0..sroa.111.6., %60
  br i1 %124, label %125, label %.critedge.7

125:                                              ; preds = %123
  store i8 %.sroa.111.0..sroa.111.6., ptr %.sroa.121, align 1, !tbaa !13
  %.sroa.98.0..sroa.98.5. = load i8, ptr %.sroa.98, align 1, !tbaa !13
  %126 = icmp ugt i8 %.sroa.98.0..sroa.98.5., %60
  br i1 %126, label %127, label %.critedge.7

127:                                              ; preds = %125
  store i8 %.sroa.98.0..sroa.98.5., ptr %.sroa.111, align 1, !tbaa !13
  %.sroa.82.0..sroa.82.4.142 = load i8, ptr %.sroa.82, align 1, !tbaa !13
  %128 = icmp ugt i8 %.sroa.82.0..sroa.82.4.142, %60
  br i1 %128, label %129, label %.critedge.7

129:                                              ; preds = %127
  store i8 %.sroa.82.0..sroa.82.4.142, ptr %.sroa.98, align 1, !tbaa !13
  %.sroa.63.0..sroa.63.3. = load i8, ptr %.sroa.63, align 1, !tbaa !13
  %130 = icmp ugt i8 %.sroa.63.0..sroa.63.3., %60
  br i1 %130, label %131, label %.critedge.7

131:                                              ; preds = %129
  store i8 %.sroa.63.0..sroa.63.3., ptr %.sroa.82, align 1, !tbaa !13
  %.sroa.42.0..sroa.42.2. = load i8, ptr %.sroa.42, align 1, !tbaa !13
  %132 = icmp ugt i8 %.sroa.42.0..sroa.42.2., %60
  br i1 %132, label %133, label %.critedge.7

133:                                              ; preds = %131
  store i8 %.sroa.42.0..sroa.42.2., ptr %.sroa.63, align 1, !tbaa !13
  %.sroa.18.0..sroa.18.1. = load i8, ptr %.sroa.18, align 1, !tbaa !13
  %134 = icmp ugt i8 %.sroa.18.0..sroa.18.1., %60
  br i1 %134, label %135, label %.critedge.7

135:                                              ; preds = %133
  store i8 %.sroa.18.0..sroa.18.1., ptr %.sroa.42, align 1, !tbaa !13
  %.sroa.0.0..sroa.0.0. = load i8, ptr %.sroa.0, align 1, !tbaa !13
  %136 = icmp ugt i8 %.sroa.0.0..sroa.0.0., %60
  br i1 %136, label %137, label %.critedge.7

137:                                              ; preds = %135
  store i8 %.sroa.0.0..sroa.0.0., ptr %.sroa.18, align 1, !tbaa !13
  br label %.critedge.7

.critedge.7:                                      ; preds = %137, %135, %133, %131, %129, %127, %125, %123, %.critedge.6
  %.0.lcssa.7.sroa.phi = phi ptr [ %.sroa.128, %.critedge.6 ], [ %.sroa.121, %123 ], [ %.sroa.111, %125 ], [ %.sroa.98, %127 ], [ %.sroa.82, %129 ], [ %.sroa.63, %131 ], [ %.sroa.42, %133 ], [ %.sroa.18, %135 ], [ %.sroa.0, %137 ]
  store i8 %60, ptr %.0.lcssa.7.sroa.phi, align 1, !tbaa !13
  %.sroa.82.0..sroa.82.4. = load i8, ptr %.sroa.82, align 1, !tbaa !13
  %138 = mul nsw i32 %21, %20
  %139 = add nsw i32 %138, %.04658
  %140 = sext i32 %139 to i64
  %141 = getelementptr inbounds i8, ptr %6, i64 %140
  store i8 %.sroa.82.0..sroa.82.4., ptr %141, align 1, !tbaa !13
  %142 = add nuw nsw i32 %.04658, 1
  %143 = load i32, ptr %0, align 8, !tbaa !12
  %144 = add nsw i32 %143, -1
  %145 = icmp slt i32 %142, %144
  br i1 %145, label %.preheader50, label %._crit_edge.loopexit, !llvm.loop !17
}

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

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

!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 = !{!8, !8, i64 0}
!14 = distinct !{!14, !15, !16}
!15 = !{!"llvm.loop.mustprogress"}
!16 = !{!"llvm.loop.unswitch.partial.disable"}
!17 = distinct !{!17, !15}


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