; LLVM IR from giacomo-ascari/dichotomic-compression :: legacy/dc/dc.ll (dc_get_delta)

; 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._dc_pixel = type { i8, i8, i8 }
%struct._dc_compression = type { i32, i8, i64, i64, ptr, ptr, i8, ptr, ptr }
%struct._dc_pixel_matrix = type { ptr, i32, i32 }
%struct._dc_corners = type { i32, i32, i32, i32 }

@__const._dc_get_delta.min_pix = external hidden unnamed_addr constant %struct._dc_pixel, 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: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @_dc_get_delta(ptr noundef %0, ptr noundef %1, i32 noundef %2) #3 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca %struct._dc_pixel, align 1
  %8 = alloca %struct._dc_pixel, align 1
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca ptr, align 8
  %14 = alloca i64, align 8
  %15 = alloca i32, align 4
  %16 = alloca i64, align 8
  %17 = alloca ptr, align 8
  %18 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i32 %2, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 3, ptr %7) #4
  call void @llvm.memset.p0.i64(ptr align 1 %7, i8 0, i64 3, i1 false)
  call void @llvm.lifetime.start.p0(i64 3, ptr %8) #4
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %8, ptr align 1 @__const._dc_get_delta.min_pix, i64 3, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct._dc_compression, ptr %19, i32 0, i32 7
  %21 = load ptr, ptr %20, align 8, !tbaa !11
  %22 = getelementptr inbounds %struct._dc_pixel_matrix, ptr %21, i32 0, i32 1
  %23 = load i32, ptr %22, align 8, !tbaa !14
  store i32 %23, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  store i32 0, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  store i32 255, ptr %12, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct._dc_compression, ptr %24, i32 0, i32 7
  %26 = load ptr, ptr %25, align 8, !tbaa !11
  %27 = getelementptr inbounds %struct._dc_pixel_matrix, ptr %26, i32 0, i32 0
  %28 = load ptr, ptr %27, align 8, !tbaa !16
  store ptr %28, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  %29 = load ptr, ptr %5, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct._dc_corners, ptr %29, i32 0, i32 1
  %31 = load i32, ptr %30, align 4, !tbaa !17
  %32 = sext i32 %31 to i64
  store i64 %32, ptr %14, align 8, !tbaa !19
  br label %33

33:                                               ; preds = %175, %3
  %34 = load i64, ptr %14, align 8, !tbaa !19
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct._dc_corners, ptr %35, i32 0, i32 3
  %37 = load i32, ptr %36, align 4, !tbaa !20
  %38 = sext i32 %37 to i64
  %39 = icmp ult i64 %34, %38
  br i1 %39, label %41, label %40

40:                                               ; preds = %33
  store i32 2, ptr %15, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  br label %178

41:                                               ; preds = %33
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #4
  %42 = load ptr, ptr %5, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct._dc_corners, ptr %42, i32 0, i32 0
  %44 = load i32, ptr %43, align 4, !tbaa !21
  %45 = sext i32 %44 to i64
  store i64 %45, ptr %16, align 8, !tbaa !19
  br label %46

46:                                               ; preds = %171, %41
  %47 = load i64, ptr %16, align 8, !tbaa !19
  %48 = load ptr, ptr %5, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct._dc_corners, ptr %48, i32 0, i32 2
  %50 = load i32, ptr %49, align 4, !tbaa !22
  %51 = sext i32 %50 to i64
  %52 = icmp ult i64 %47, %51
  br i1 %52, label %54, label %53

53:                                               ; preds = %46
  store i32 5, ptr %15, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #4
  br label %174

54:                                               ; preds = %46
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #4
  %55 = load ptr, ptr %13, align 8, !tbaa !5
  %56 = load i64, ptr %16, align 8, !tbaa !19
  %57 = trunc i64 %56 to i32
  %58 = load i64, ptr %14, align 8, !tbaa !19
  %59 = trunc i64 %58 to i32
  %60 = load i32, ptr %9, align 4, !tbaa !9
  %61 = call i32 @ix(i32 noundef %57, i32 noundef %59, i32 noundef %60)
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds %struct._dc_pixel, ptr %55, i64 %62
  store ptr %63, ptr %17, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #4
  %64 = load ptr, ptr %4, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct._dc_compression, ptr %64, i32 0, i32 1
  %66 = load i8, ptr %65, align 4, !tbaa !23
  %67 = zext i8 %66 to i32
  switch i32 %67, label %169 [
    i32 1, label %68
    i32 2, label %153
  ]

68:                                               ; preds = %54
  %69 = load ptr, ptr %17, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct._dc_pixel, ptr %69, i32 0, i32 0
  %71 = load i8, ptr %70, align 1, !tbaa !24
  %72 = zext i8 %71 to i32
  %73 = getelementptr inbounds %struct._dc_pixel, ptr %7, i32 0, i32 0
  %74 = load i8, ptr %73, align 1, !tbaa !24
  %75 = zext i8 %74 to i32
  %76 = icmp sgt i32 %72, %75
  br i1 %76, label %77, label %82

77:                                               ; preds = %68
  %78 = load ptr, ptr %17, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct._dc_pixel, ptr %78, i32 0, i32 0
  %80 = load i8, ptr %79, align 1, !tbaa !24
  %81 = getelementptr inbounds %struct._dc_pixel, ptr %7, i32 0, i32 0
  store i8 %80, ptr %81, align 1, !tbaa !24
  br label %82

82:                                               ; preds = %77, %68
  %83 = load ptr, ptr %17, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct._dc_pixel, ptr %83, i32 0, i32 1
  %85 = load i8, ptr %84, align 1, !tbaa !26
  %86 = zext i8 %85 to i32
  %87 = getelementptr inbounds %struct._dc_pixel, ptr %7, i32 0, i32 1
  %88 = load i8, ptr %87, align 1, !tbaa !26
  %89 = zext i8 %88 to i32
  %90 = icmp sgt i32 %86, %89
  br i1 %90, label %91, label %96

91:                                               ; preds = %82
  %92 = load ptr, ptr %17, align 8, !tbaa !5
  %93 = getelementptr inbounds %struct._dc_pixel, ptr %92, i32 0, i32 1
  %94 = load i8, ptr %93, align 1, !tbaa !26
  %95 = getelementptr inbounds %struct._dc_pixel, ptr %7, i32 0, i32 1
  store i8 %94, ptr %95, align 1, !tbaa !26
  br label %96

96:                                               ; preds = %91, %82
  %97 = load ptr, ptr %17, align 8, !tbaa !5
  %98 = getelementptr inbounds %struct._dc_pixel, ptr %97, i32 0, i32 2
  %99 = load i8, ptr %98, align 1, !tbaa !27
  %100 = zext i8 %99 to i32
  %101 = getelementptr inbounds %struct._dc_pixel, ptr %7, i32 0, i32 2
  %102 = load i8, ptr %101, align 1, !tbaa !27
  %103 = zext i8 %102 to i32
  %104 = icmp sgt i32 %100, %103
  br i1 %104, label %105, label %110

105:                                              ; preds = %96
  %106 = load ptr, ptr %17, align 8, !tbaa !5
  %107 = getelementptr inbounds %struct._dc_pixel, ptr %106, i32 0, i32 2
  %108 = load i8, ptr %107, align 1, !tbaa !27
  %109 = getelementptr inbounds %struct._dc_pixel, ptr %7, i32 0, i32 2
  store i8 %108, ptr %109, align 1, !tbaa !27
  br label %110

110:                                              ; preds = %105, %96
  %111 = load ptr, ptr %17, align 8, !tbaa !5
  %112 = getelementptr inbounds %struct._dc_pixel, ptr %111, i32 0, i32 0
  %113 = load i8, ptr %112, align 1, !tbaa !24
  %114 = zext i8 %113 to i32
  %115 = getelementptr inbounds %struct._dc_pixel, ptr %8, i32 0, i32 0
  %116 = load i8, ptr %115, align 1, !tbaa !24
  %117 = zext i8 %116 to i32
  %118 = icmp slt i32 %114, %117
  br i1 %118, label %119, label %124

119:                                              ; preds = %110
  %120 = load ptr, ptr %17, align 8, !tbaa !5
  %121 = getelementptr inbounds %struct._dc_pixel, ptr %120, i32 0, i32 0
  %122 = load i8, ptr %121, align 1, !tbaa !24
  %123 = getelementptr inbounds %struct._dc_pixel, ptr %8, i32 0, i32 0
  store i8 %122, ptr %123, align 1, !tbaa !24
  br label %124

124:                                              ; preds = %119, %110
  %125 = load ptr, ptr %17, align 8, !tbaa !5
  %126 = getelementptr inbounds %struct._dc_pixel, ptr %125, i32 0, i32 1
  %127 = load i8, ptr %126, align 1, !tbaa !26
  %128 = zext i8 %127 to i32
  %129 = getelementptr inbounds %struct._dc_pixel, ptr %8, i32 0, i32 1
  %130 = load i8, ptr %129, align 1, !tbaa !26
  %131 = zext i8 %130 to i32
  %132 = icmp slt i32 %128, %131
  br i1 %132, label %133, label %138

133:                                              ; preds = %124
  %134 = load ptr, ptr %17, align 8, !tbaa !5
  %135 = getelementptr inbounds %struct._dc_pixel, ptr %134, i32 0, i32 1
  %136 = load i8, ptr %135, align 1, !tbaa !26
  %137 = getelementptr inbounds %struct._dc_pixel, ptr %8, i32 0, i32 1
  store i8 %136, ptr %137, align 1, !tbaa !26
  br label %138

138:                                              ; preds = %133, %124
  %139 = load ptr, ptr %17, align 8, !tbaa !5
  %140 = getelementptr inbounds %struct._dc_pixel, ptr %139, i32 0, i32 2
  %141 = load i8, ptr %140, align 1, !tbaa !27
  %142 = zext i8 %141 to i32
  %143 = getelementptr inbounds %struct._dc_pixel, ptr %8, i32 0, i32 2
  %144 = load i8, ptr %143, align 1, !tbaa !27
  %145 = zext i8 %144 to i32
  %146 = icmp slt i32 %142, %145
  br i1 %146, label %147, label %152

147:                                              ; preds = %138
  %148 = load ptr, ptr %17, align 8, !tbaa !5
  %149 = getelementptr inbounds %struct._dc_pixel, ptr %148, i32 0, i32 2
  %150 = load i8, ptr %149, align 1, !tbaa !27
  %151 = getelementptr inbounds %struct._dc_pixel, ptr %8, i32 0, i32 2
  store i8 %150, ptr %151, align 1, !tbaa !27
  br label %152

152:                                              ; preds = %147, %138
  br label %170

153:                                              ; preds = %54
  %154 = load ptr, ptr %17, align 8, !tbaa !5
  %155 = load i32, ptr %6, align 4, !tbaa !9
  %156 = call i32 @_dc_get_channel(ptr noundef %154, i32 noundef %155)
  store i32 %156, ptr %18, align 4, !tbaa !9
  %157 = load i32, ptr %18, align 4, !tbaa !9
  %158 = load i32, ptr %11, align 4, !tbaa !9
  %159 = icmp sgt i32 %157, %158
  br i1 %159, label %160, label %162

160:                                              ; preds = %153
  %161 = load i32, ptr %18, align 4, !tbaa !9
  store i32 %161, ptr %11, align 4, !tbaa !9
  br label %162

162:                                              ; preds = %160, %153
  %163 = load i32, ptr %18, align 4, !tbaa !9
  %164 = load i32, ptr %12, align 4, !tbaa !9
  %165 = icmp slt i32 %163, %164
  br i1 %165, label %166, label %168

166:                                              ; preds = %162
  %167 = load i32, ptr %18, align 4, !tbaa !9
  store i32 %167, ptr %12, align 4, !tbaa !9
  br label %168

168:                                              ; preds = %166, %162
  br label %170

169:                                              ; preds = %54
  br label %170

170:                                              ; preds = %169, %168, %152
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #4
  br label %171

171:                                              ; preds = %170
  %172 = load i64, ptr %16, align 8, !tbaa !19
  %173 = add i64 %172, 1
  store i64 %173, ptr %16, align 8, !tbaa !19
  br label %46, !llvm.loop !28

174:                                              ; preds = %53
  br label %175

175:                                              ; preds = %174
  %176 = load i64, ptr %14, align 8, !tbaa !19
  %177 = add i64 %176, 1
  store i64 %177, ptr %14, align 8, !tbaa !19
  br label %33, !llvm.loop !30

178:                                              ; preds = %40
  %179 = load ptr, ptr %4, align 8, !tbaa !5
  %180 = getelementptr inbounds %struct._dc_compression, ptr %179, i32 0, i32 1
  %181 = load i8, ptr %180, align 4, !tbaa !23
  %182 = zext i8 %181 to i32
  switch i32 %182, label %212 [
    i32 1, label %183
    i32 2, label %208
  ]

183:                                              ; preds = %178
  %184 = getelementptr inbounds %struct._dc_pixel, ptr %7, i32 0, i32 0
  %185 = load i8, ptr %184, align 1, !tbaa !24
  %186 = zext i8 %185 to i32
  %187 = getelementptr inbounds %struct._dc_pixel, ptr %8, i32 0, i32 0
  %188 = load i8, ptr %187, align 1, !tbaa !24
  %189 = zext i8 %188 to i32
  %190 = sub nsw i32 %186, %189
  %191 = getelementptr inbounds %struct._dc_pixel, ptr %7, i32 0, i32 1
  %192 = load i8, ptr %191, align 1, !tbaa !26
  %193 = zext i8 %192 to i32
  %194 = add nsw i32 %190, %193
  %195 = getelementptr inbounds %struct._dc_pixel, ptr %8, i32 0, i32 1
  %196 = load i8, ptr %195, align 1, !tbaa !26
  %197 = zext i8 %196 to i32
  %198 = sub nsw i32 %194, %197
  %199 = getelementptr inbounds %struct._dc_pixel, ptr %7, i32 0, i32 2
  %200 = load i8, ptr %199, align 1, !tbaa !27
  %201 = zext i8 %200 to i32
  %202 = add nsw i32 %198, %201
  %203 = getelementptr inbounds %struct._dc_pixel, ptr %8, i32 0, i32 2
  %204 = load i8, ptr %203, align 1, !tbaa !27
  %205 = zext i8 %204 to i32
  %206 = sub nsw i32 %202, %205
  %207 = sdiv i32 %206, 3
  store i32 %207, ptr %10, align 4, !tbaa !9
  br label %213

208:                                              ; preds = %178
  %209 = load i32, ptr %11, align 4, !tbaa !9
  %210 = load i32, ptr %12, align 4, !tbaa !9
  %211 = sub nsw i32 %209, %210
  store i32 %211, ptr %10, align 4, !tbaa !9
  br label %213

212:                                              ; preds = %178
  br label %213

213:                                              ; preds = %212, %208, %183
  %214 = load i32, ptr %10, align 4, !tbaa !9
  store i32 1, ptr %15, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 3, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 3, ptr %7) #4
  ret i32 %214
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 = { 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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 48}
!12 = !{!"_dc_compression", !10, i64 0, !7, i64 4, !13, i64 8, !13, i64 16, !6, i64 24, !6, i64 32, !7, i64 40, !6, i64 48, !6, i64 56}
!13 = !{!"long", !7, i64 0}
!14 = !{!15, !10, i64 8}
!15 = !{!"_dc_pixel_matrix", !6, i64 0, !10, i64 8, !10, i64 12}
!16 = !{!15, !6, i64 0}
!17 = !{!18, !10, i64 4}
!18 = !{!"_dc_corners", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12}
!19 = !{!13, !13, i64 0}
!20 = !{!18, !10, i64 12}
!21 = !{!18, !10, i64 0}
!22 = !{!18, !10, i64 8}
!23 = !{!12, !7, i64 4}
!24 = !{!25, !7, i64 0}
!25 = !{!"_dc_pixel", !7, i64 0, !7, i64 1, !7, i64 2}
!26 = !{!25, !7, i64 1}
!27 = !{!25, !7, i64 2}
!28 = distinct !{!28, !29}
!29 = !{!"llvm.loop.mustprogress"}
!30 = distinct !{!30, !29}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%struct._dc_pixel = type { i8, i8, i8 }

@__const._dc_get_delta.min_pix = external hidden unnamed_addr constant %struct._dc_pixel, align 1

; Function Attrs: nounwind uwtable
declare dso_local i32 @ix(i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @_dc_get_channel(ptr noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local i32 @_dc_get_delta(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1, i32 noundef %2) local_unnamed_addr #0 {
  %.sroa.0.0.copyload = load i8, ptr @__const._dc_get_delta.min_pix, align 1
  %.sroa.6.0.copyload = load i8, ptr getelementptr inbounds (i8, ptr @__const._dc_get_delta.min_pix, i64 1), align 1
  %.sroa.9.0.copyload = load i8, ptr getelementptr inbounds (i8, ptr @__const._dc_get_delta.min_pix, i64 2), align 1
  %4 = getelementptr inbounds i8, ptr %0, i64 48
  %5 = load ptr, ptr %4, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %5, i64 8
  %7 = load i32, ptr %6, align 8, !tbaa !12
  %8 = load ptr, ptr %5, align 8, !tbaa !14
  %9 = getelementptr inbounds i8, ptr %1, i64 4
  %10 = load i32, ptr %9, align 4, !tbaa !15
  %11 = getelementptr inbounds i8, ptr %1, i64 12
  %12 = load i32, ptr %11, align 4, !tbaa !17
  %13 = icmp ult i32 %10, %12
  br i1 %13, label %.lr.ph90, label %._crit_edge91

.lr.ph90:                                         ; preds = %3
  %14 = sext i32 %10 to i64
  %15 = getelementptr inbounds i8, ptr %1, i64 8
  %16 = getelementptr inbounds i8, ptr %0, i64 4
  %.pre = load i32, ptr %15, align 4, !tbaa !18
  br label %22

._crit_edge91.loopexit:                           ; preds = %._crit_edge
  %17 = zext i8 %.sroa.032.1.lcssa to i16
  %18 = zext i8 %.sroa.634.1.lcssa to i16
  %19 = zext i8 %.sroa.936.1.lcssa to i16
  br label %._crit_edge91

._crit_edge91:                                    ; preds = %._crit_edge91.loopexit, %3
  %.sroa.6.0.lcssa = phi i8 [ %.sroa.6.0.copyload, %3 ], [ %.sroa.6.1.lcssa, %._crit_edge91.loopexit ]
  %.sroa.0.0.lcssa = phi i8 [ %.sroa.0.0.copyload, %3 ], [ %.sroa.0.1.lcssa, %._crit_edge91.loopexit ]
  %.sroa.9.0.lcssa = phi i8 [ %.sroa.9.0.copyload, %3 ], [ %.sroa.9.1.lcssa, %._crit_edge91.loopexit ]
  %.051.lcssa = phi i32 [ 0, %3 ], [ %.152.lcssa, %._crit_edge91.loopexit ]
  %.050.lcssa = phi i32 [ 255, %3 ], [ %.1.lcssa, %._crit_edge91.loopexit ]
  %.sroa.936.0.lcssa = phi i16 [ 0, %3 ], [ %19, %._crit_edge91.loopexit ]
  %.sroa.634.0.lcssa = phi i16 [ 0, %3 ], [ %18, %._crit_edge91.loopexit ]
  %.sroa.032.0.lcssa = phi i16 [ 0, %3 ], [ %17, %._crit_edge91.loopexit ]
  %20 = getelementptr inbounds i8, ptr %0, i64 4
  %21 = load i8, ptr %20, align 4, !tbaa !19
  switch i8 %21, label %64 [
    i8 1, label %53
    i8 2, label %62
  ]

22:                                               ; preds = %.lr.ph90, %._crit_edge
  %23 = phi i32 [ %12, %.lr.ph90 ], [ %29, %._crit_edge ]
  %24 = phi i32 [ %.pre, %.lr.ph90 ], [ %30, %._crit_edge ]
  %.sroa.032.088 = phi i8 [ 0, %.lr.ph90 ], [ %.sroa.032.1.lcssa, %._crit_edge ]
  %.sroa.634.087 = phi i8 [ 0, %.lr.ph90 ], [ %.sroa.634.1.lcssa, %._crit_edge ]
  %.04986 = phi i64 [ %14, %.lr.ph90 ], [ %31, %._crit_edge ]
  %.sroa.936.085 = phi i8 [ 0, %.lr.ph90 ], [ %.sroa.936.1.lcssa, %._crit_edge ]
  %.05084 = phi i32 [ 255, %.lr.ph90 ], [ %.1.lcssa, %._crit_edge ]
  %.05183 = phi i32 [ 0, %.lr.ph90 ], [ %.152.lcssa, %._crit_edge ]
  %.sroa.9.082 = phi i8 [ %.sroa.9.0.copyload, %.lr.ph90 ], [ %.sroa.9.1.lcssa, %._crit_edge ]
  %.sroa.0.081 = phi i8 [ %.sroa.0.0.copyload, %.lr.ph90 ], [ %.sroa.0.1.lcssa, %._crit_edge ]
  %.sroa.6.080 = phi i8 [ %.sroa.6.0.copyload, %.lr.ph90 ], [ %.sroa.6.1.lcssa, %._crit_edge ]
  %25 = load i32, ptr %1, align 4, !tbaa !20
  %26 = icmp ult i32 %25, %24
  br i1 %26, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %22
  %27 = sext i32 %25 to i64
  %28 = trunc i64 %.04986 to i32
  br label %34

._crit_edge.loopexit:                             ; preds = %48
  %.pre100 = load i32, ptr %11, align 4, !tbaa !17
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %22
  %29 = phi i32 [ %23, %22 ], [ %.pre100, %._crit_edge.loopexit ]
  %30 = phi i32 [ %24, %22 ], [ %50, %._crit_edge.loopexit ]
  %.sroa.6.1.lcssa = phi i8 [ %.sroa.6.080, %22 ], [ %.sroa.6.3, %._crit_edge.loopexit ]
  %.sroa.0.1.lcssa = phi i8 [ %.sroa.0.081, %22 ], [ %.sroa.0.3, %._crit_edge.loopexit ]
  %.sroa.9.1.lcssa = phi i8 [ %.sroa.9.082, %22 ], [ %.sroa.9.2, %._crit_edge.loopexit ]
  %.152.lcssa = phi i32 [ %.05183, %22 ], [ %.3, %._crit_edge.loopexit ]
  %.1.lcssa = phi i32 [ %.05084, %22 ], [ %.2, %._crit_edge.loopexit ]
  %.sroa.936.1.lcssa = phi i8 [ %.sroa.936.085, %22 ], [ %.sroa.936.3, %._crit_edge.loopexit ]
  %.sroa.634.1.lcssa = phi i8 [ %.sroa.634.087, %22 ], [ %.sroa.634.3, %._crit_edge.loopexit ]
  %.sroa.032.1.lcssa = phi i8 [ %.sroa.032.088, %22 ], [ %.sroa.032.3, %._crit_edge.loopexit ]
  %31 = add i64 %.04986, 1
  %32 = sext i32 %29 to i64
  %33 = icmp ult i64 %31, %32
  br i1 %33, label %22, label %._crit_edge91.loopexit, !llvm.loop !21

34:                                               ; preds = %.lr.ph, %48
  %.sroa.032.172 = phi i8 [ %.sroa.032.088, %.lr.ph ], [ %.sroa.032.3, %48 ]
  %.sroa.634.171 = phi i8 [ %.sroa.634.087, %.lr.ph ], [ %.sroa.634.3, %48 ]
  %.070 = phi i64 [ %27, %.lr.ph ], [ %49, %48 ]
  %.sroa.936.169 = phi i8 [ %.sroa.936.085, %.lr.ph ], [ %.sroa.936.3, %48 ]
  %.168 = phi i32 [ %.05084, %.lr.ph ], [ %.2, %48 ]
  %.15267 = phi i32 [ %.05183, %.lr.ph ], [ %.3, %48 ]
  %.sroa.9.166 = phi i8 [ %.sroa.9.082, %.lr.ph ], [ %.sroa.9.2, %48 ]
  %.sroa.0.165 = phi i8 [ %.sroa.0.081, %.lr.ph ], [ %.sroa.0.3, %48 ]
  %.sroa.6.164 = phi i8 [ %.sroa.6.080, %.lr.ph ], [ %.sroa.6.3, %48 ]
  %35 = trunc i64 %.070 to i32
  %36 = tail call i32 @ix(i32 noundef %35, i32 noundef %28, i32 noundef %7)
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds %struct._dc_pixel, ptr %8, i64 %37
  %39 = load i8, ptr %16, align 4, !tbaa !19
  switch i8 %39, label %48 [
    i8 1, label %40
    i8 2, label %46
  ]

40:                                               ; preds = %34
  %41 = load i8, ptr %38, align 1, !tbaa !23
  %spec.select = tail call i8 @llvm.umax.i8(i8 %41, i8 %.sroa.032.172)
  %42 = getelementptr inbounds i8, ptr %38, i64 1
  %43 = load i8, ptr %42, align 1, !tbaa !25
  %.sroa.634.2 = tail call i8 @llvm.umax.i8(i8 %43, i8 %.sroa.634.171)
  %44 = getelementptr inbounds i8, ptr %38, i64 2
  %45 = load i8, ptr %44, align 1, !tbaa !26
  %.sroa.936.2 = tail call i8 @llvm.umax.i8(i8 %45, i8 %.sroa.936.169)
  %.sroa.0.2 = tail call i8 @llvm.umin.i8(i8 %41, i8 %.sroa.0.165)
  %.sroa.6.2 = tail call i8 @llvm.umin.i8(i8 %43, i8 %.sroa.6.164)
  %spec.select59 = tail call i8 @llvm.umin.i8(i8 %45, i8 %.sroa.9.166)
  br label %48

46:                                               ; preds = %34
  %47 = tail call i32 @_dc_get_channel(ptr noundef %38, i32 noundef %2)
  %spec.select57 = tail call i32 @llvm.smax.i32(i32 %47, i32 %.15267)
  %spec.select58 = tail call i32 @llvm.smin.i32(i32 %47, i32 %.168)
  br label %48

48:                                               ; preds = %40, %46, %34
  %.sroa.6.3 = phi i8 [ %.sroa.6.164, %34 ], [ %.sroa.6.164, %46 ], [ %.sroa.6.2, %40 ]
  %.sroa.0.3 = phi i8 [ %.sroa.0.165, %34 ], [ %.sroa.0.165, %46 ], [ %.sroa.0.2, %40 ]
  %.sroa.9.2 = phi i8 [ %.sroa.9.166, %34 ], [ %.sroa.9.166, %46 ], [ %spec.select59, %40 ]
  %.3 = phi i32 [ %.15267, %34 ], [ %spec.select57, %46 ], [ %.15267, %40 ]
  %.2 = phi i32 [ %.168, %34 ], [ %spec.select58, %46 ], [ %.168, %40 ]
  %.sroa.936.3 = phi i8 [ %.sroa.936.169, %34 ], [ %.sroa.936.169, %46 ], [ %.sroa.936.2, %40 ]
  %.sroa.634.3 = phi i8 [ %.sroa.634.171, %34 ], [ %.sroa.634.171, %46 ], [ %.sroa.634.2, %40 ]
  %.sroa.032.3 = phi i8 [ %.sroa.032.172, %34 ], [ %.sroa.032.172, %46 ], [ %spec.select, %40 ]
  %49 = add nuw i64 %.070, 1
  %50 = load i32, ptr %15, align 4, !tbaa !18
  %51 = sext i32 %50 to i64
  %52 = icmp ult i64 %49, %51
  br i1 %52, label %34, label %._crit_edge.loopexit, !llvm.loop !27

53:                                               ; preds = %._crit_edge91
  %54 = zext i8 %.sroa.0.0.lcssa to i16
  %55 = zext i8 %.sroa.6.0.lcssa to i16
  %56 = zext i8 %.sroa.9.0.lcssa to i16
  %57 = add nuw nsw i16 %54, %55
  %58 = add nuw nsw i16 %57, %56
  %59 = sub nsw i16 %.sroa.936.0.lcssa, %58
  %60 = add nsw i16 %59, %.sroa.634.0.lcssa
  %.lhs.trunc = add nsw i16 %60, %.sroa.032.0.lcssa
  %61 = sdiv i16 %.lhs.trunc, 3
  %.sext = sext i16 %61 to i32
  br label %64

62:                                               ; preds = %._crit_edge91
  %63 = sub nsw i32 %.051.lcssa, %.050.lcssa
  br label %64

64:                                               ; preds = %._crit_edge91, %62, %53
  %.054 = phi i32 [ undef, %._crit_edge91 ], [ %63, %62 ], [ %.sext, %53 ]
  ret i32 %.054
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smax.i32(i32, i32) #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smin.i32(i32, i32) #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i8 @llvm.umax.i8(i8, i8) #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i8 @llvm.umin.i8(i8, i8) #1

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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, !11, i64 48}
!6 = !{!"_dc_compression", !7, i64 0, !8, i64 4, !10, i64 8, !10, i64 16, !11, i64 24, !11, i64 32, !8, i64 40, !11, i64 48, !11, i64 56}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!13, !7, i64 8}
!13 = !{!"_dc_pixel_matrix", !11, i64 0, !7, i64 8, !7, i64 12}
!14 = !{!13, !11, i64 0}
!15 = !{!16, !7, i64 4}
!16 = !{!"_dc_corners", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12}
!17 = !{!16, !7, i64 12}
!18 = !{!16, !7, i64 8}
!19 = !{!6, !8, i64 4}
!20 = !{!16, !7, i64 0}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}
!23 = !{!24, !8, i64 0}
!24 = !{!"_dc_pixel", !8, i64 0, !8, i64 1, !8, i64 2}
!25 = !{!24, !8, i64 1}
!26 = !{!24, !8, i64 2}
!27 = distinct !{!27, !22}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass