; LLVM IR from zchrissirhcz/pixel :: src (px_histogram)

; 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.px_image_t = type { ptr, i32, i32, i32, i32 }

@.str = external hidden unnamed_addr constant [27 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [71 x i8], align 1
@__PRETTY_FUNCTION__.px_histogram_rgb = external hidden unnamed_addr constant [62 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [19 x i8], align 1
@stderr = external global ptr, align 8
@.str.3 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local ptr @px_histogram_rgb(ptr noundef %0, i32 noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca [256 x i32], align 16
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca ptr, align 8
  %18 = alloca i32, align 4
  %19 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = call zeroext i1 @px_is_valid_rgb_image(ptr noundef %20)
  br i1 %21, label %22, label %23

22:                                               ; preds = %2
  br label %24

23:                                               ; preds = %2
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 41, ptr noundef @__PRETTY_FUNCTION__.px_histogram_rgb) #6
  unreachable

24:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #7
  store i32 3, ptr %6, align 4, !tbaa !9
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.px_image_t, ptr %25, i32 0, i32 3
  %27 = load i32, ptr %26, align 8, !tbaa !11
  %28 = icmp eq i32 %27, 3
  br i1 %28, label %29, label %30

29:                                               ; preds = %24
  br label %31

30:                                               ; preds = %24
  call void @__assert_fail(ptr noundef @.str.2, ptr noundef @.str.1, i32 noundef 44, ptr noundef @__PRETTY_FUNCTION__.px_histogram_rgb) #6
  unreachable

31:                                               ; preds = %29
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #7
  %32 = load ptr, ptr %4, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.px_image_t, ptr %32, i32 0, i32 2
  %34 = load i32, ptr %33, align 4, !tbaa !13
  store i32 %34, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #7
  %35 = load ptr, ptr %4, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.px_image_t, ptr %35, i32 0, i32 1
  %37 = load i32, ptr %36, align 8, !tbaa !14
  store i32 %37, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 1024, ptr %9) #7
  call void @llvm.memset.p0.i64(ptr align 16 %9, i8 0, i64 1024, i1 false)
  %38 = load i32, ptr %5, align 4, !tbaa !9
  %39 = icmp eq i32 %38, 0
  br i1 %39, label %40, label %93

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

41:                                               ; preds = %89, %40
  %42 = load i32, ptr %10, align 4, !tbaa !9
  %43 = load i32, ptr %7, align 4, !tbaa !9
  %44 = icmp slt i32 %42, %43
  br i1 %44, label %46, label %45

45:                                               ; preds = %41
  store i32 2, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #7
  br label %92

46:                                               ; preds = %41
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #7
  %47 = load ptr, ptr %4, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.px_image_t, ptr %47, i32 0, i32 0
  %49 = load ptr, ptr %48, align 8, !tbaa !15
  %50 = load i32, ptr %10, align 4, !tbaa !9
  %51 = load ptr, ptr %4, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.px_image_t, ptr %51, i32 0, i32 4
  %53 = load i32, ptr %52, align 4, !tbaa !16
  %54 = mul nsw i32 %50, %53
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds i8, ptr %49, i64 %55
  store ptr %56, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #7
  store i32 0, ptr %13, align 4, !tbaa !9
  br label %57

57:                                               ; preds = %85, %46
  %58 = load i32, ptr %13, align 4, !tbaa !9
  %59 = load i32, ptr %8, align 4, !tbaa !9
  %60 = icmp slt i32 %58, %59
  br i1 %60, label %62, label %61

61:                                               ; preds = %57
  store i32 5, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #7
  br label %88

62:                                               ; preds = %57
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #7
  %63 = load ptr, ptr %12, align 8, !tbaa !5
  %64 = getelementptr inbounds i8, ptr %63, i64 0
  %65 = load i8, ptr %64, align 1, !tbaa !17
  %66 = zext i8 %65 to i32
  %67 = load ptr, ptr %12, align 8, !tbaa !5
  %68 = getelementptr inbounds i8, ptr %67, i64 1
  %69 = load i8, ptr %68, align 1, !tbaa !17
  %70 = zext i8 %69 to i32
  %71 = add nsw i32 %66, %70
  %72 = load ptr, ptr %12, align 8, !tbaa !5
  %73 = getelementptr inbounds i8, ptr %72, i64 2
  %74 = load i8, ptr %73, align 1, !tbaa !17
  %75 = zext i8 %74 to i32
  %76 = add nsw i32 %71, %75
  %77 = sdiv i32 %76, 3
  store i32 %77, ptr %14, align 4, !tbaa !9
  %78 = load i32, ptr %14, align 4, !tbaa !9
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds [256 x i32], ptr %9, i64 0, i64 %79
  %81 = load i32, ptr %80, align 4, !tbaa !9
  %82 = add nsw i32 %81, 1
  store i32 %82, ptr %80, align 4, !tbaa !9
  %83 = load ptr, ptr %12, align 8, !tbaa !5
  %84 = getelementptr inbounds i8, ptr %83, i64 3
  store ptr %84, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #7
  br label %85

85:                                               ; preds = %62
  %86 = load i32, ptr %13, align 4, !tbaa !9
  %87 = add nsw i32 %86, 1
  store i32 %87, ptr %13, align 4, !tbaa !9
  br label %57, !llvm.loop !18

88:                                               ; preds = %61
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #7
  br label %89

89:                                               ; preds = %88
  %90 = load i32, ptr %10, align 4, !tbaa !9
  %91 = add nsw i32 %90, 1
  store i32 %91, ptr %10, align 4, !tbaa !9
  br label %41, !llvm.loop !20

92:                                               ; preds = %45
  br label %161

93:                                               ; preds = %31
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #7
  store i32 0, ptr %15, align 4, !tbaa !9
  %94 = load i32, ptr %5, align 4, !tbaa !9
  %95 = icmp eq i32 %94, 1
  br i1 %95, label %96, label %97

96:                                               ; preds = %93
  store i32 0, ptr %15, align 4, !tbaa !9
  br label %116

97:                                               ; preds = %93
  %98 = load i32, ptr %5, align 4, !tbaa !9
  %99 = icmp eq i32 %98, 2
  br i1 %99, label %100, label %101

100:                                              ; preds = %97
  store i32 1, ptr %15, align 4, !tbaa !9
  br label %115

101:                                              ; preds = %97
  %102 = load i32, ptr %5, align 4, !tbaa !9
  %103 = icmp eq i32 %102, 3
  br i1 %103, label %104, label %105

104:                                              ; preds = %101
  store i32 2, ptr %15, align 4, !tbaa !9
  br label %114

105:                                              ; preds = %101
  br label %106

106:                                              ; preds = %105
  %107 = load ptr, ptr @stderr, align 8, !tbaa !5
  %108 = load i32, ptr %5, align 4, !tbaa !9
  %109 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %107, ptr noundef @.str.3, i32 noundef %108) #7
  %110 = load ptr, ptr @stderr, align 8, !tbaa !5
  %111 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %110, ptr noundef @.str.4) #7
  br label %112

112:                                              ; preds = %106
  br label %113

113:                                              ; preds = %112
  store ptr null, ptr %3, align 8
  store i32 1, ptr %11, align 4
  br label %158

114:                                              ; preds = %104
  br label %115

115:                                              ; preds = %114, %100
  br label %116

116:                                              ; preds = %115, %96
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #7
  store i32 0, ptr %16, align 4, !tbaa !9
  br label %117

117:                                              ; preds = %154, %116
  %118 = load i32, ptr %16, align 4, !tbaa !9
  %119 = load i32, ptr %7, align 4, !tbaa !9
  %120 = icmp slt i32 %118, %119
  br i1 %120, label %122, label %121

121:                                              ; preds = %117
  store i32 10, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #7
  br label %157

122:                                              ; preds = %117
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #7
  %123 = load ptr, ptr %4, align 8, !tbaa !5
  %124 = getelementptr inbounds %struct.px_image_t, ptr %123, i32 0, i32 0
  %125 = load ptr, ptr %124, align 8, !tbaa !15
  %126 = load i32, ptr %16, align 4, !tbaa !9
  %127 = load ptr, ptr %4, align 8, !tbaa !5
  %128 = getelementptr inbounds %struct.px_image_t, ptr %127, i32 0, i32 4
  %129 = load i32, ptr %128, align 4, !tbaa !16
  %130 = mul nsw i32 %126, %129
  %131 = sext i32 %130 to i64
  %132 = getelementptr inbounds i8, ptr %125, i64 %131
  %133 = load i32, ptr %15, align 4, !tbaa !9
  %134 = sext i32 %133 to i64
  %135 = getelementptr inbounds i8, ptr %132, i64 %134
  store ptr %135, ptr %17, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #7
  store i32 0, ptr %18, align 4, !tbaa !9
  br label %136

136:                                              ; preds = %150, %122
  %137 = load i32, ptr %18, align 4, !tbaa !9
  %138 = load i32, ptr %8, align 4, !tbaa !9
  %139 = icmp slt i32 %137, %138
  br i1 %139, label %141, label %140

140:                                              ; preds = %136
  store i32 13, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #7
  br label %153

141:                                              ; preds = %136
  %142 = load ptr, ptr %17, align 8, !tbaa !5
  %143 = load i8, ptr %142, align 1, !tbaa !17
  %144 = zext i8 %143 to i64
  %145 = getelementptr inbounds [256 x i32], ptr %9, i64 0, i64 %144
  %146 = load i32, ptr %145, align 4, !tbaa !9
  %147 = add nsw i32 %146, 1
  store i32 %147, ptr %145, align 4, !tbaa !9
  %148 = load ptr, ptr %17, align 8, !tbaa !5
  %149 = getelementptr inbounds i8, ptr %148, i64 3
  store ptr %149, ptr %17, align 8, !tbaa !5
  br label %150

150:                                              ; preds = %141
  %151 = load i32, ptr %18, align 4, !tbaa !9
  %152 = add nsw i32 %151, 1
  store i32 %152, ptr %18, align 4, !tbaa !9
  br label %136, !llvm.loop !21

153:                                              ; preds = %140
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #7
  br label %154

154:                                              ; preds = %153
  %155 = load i32, ptr %16, align 4, !tbaa !9
  %156 = add nsw i32 %155, 1
  store i32 %156, ptr %16, align 4, !tbaa !9
  br label %117, !llvm.loop !22

157:                                              ; preds = %121
  store i32 0, ptr %11, align 4
  br label %158

158:                                              ; preds = %157, %113
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #7
  %159 = load i32, ptr %11, align 4
  switch i32 %159, label %165 [
    i32 0, label %160
  ]

160:                                              ; preds = %158
  br label %161

161:                                              ; preds = %160, %92
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #7
  %162 = getelementptr inbounds [256 x i32], ptr %9, i64 0, i64 0
  %163 = call ptr @histogram_lut_to_image(ptr noundef %162)
  store ptr %163, ptr %19, align 8, !tbaa !5
  %164 = load ptr, ptr %19, align 8, !tbaa !5
  store ptr %164, ptr %3, align 8
  store i32 1, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #7
  br label %165

165:                                              ; preds = %161, %158
  call void @llvm.lifetime.end.p0(i64 1024, ptr %9) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #7
  %166 = load ptr, ptr %3, align 8
  ret ptr %166
}

declare zeroext i1 @px_is_valid_rgb_image(ptr noundef) #1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #2

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #4

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

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

; Function Attrs: nounwind uwtable
declare hidden ptr @histogram_lut_to_image(ptr noundef) #0

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 = { "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 = { noreturn 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 #3 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = { noreturn nounwind }
attributes #7 = { 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, !10, i64 16}
!12 = !{!"px_image_t", !6, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20}
!13 = !{!12, !10, i64 12}
!14 = !{!12, !10, i64 8}
!15 = !{!12, !6, i64 0}
!16 = !{!12, !10, i64 20}
!17 = !{!7, !7, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = distinct !{!20, !19}
!21 = distinct !{!21, !19}
!22 = distinct !{!22, !19}


; 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 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [71 x i8], align 1
@__PRETTY_FUNCTION__.px_histogram_rgb = external hidden unnamed_addr constant [62 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [19 x i8], align 1
@stderr = external local_unnamed_addr global ptr, align 8
@.str.3 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local ptr @px_histogram_rgb(ptr noundef %0, i32 noundef %1) local_unnamed_addr #0 {
  %3 = alloca [256 x i32], align 16
  %4 = tail call zeroext i1 @px_is_valid_rgb_image(ptr noundef %0) #6
  br i1 %4, label %6, label %5

5:                                                ; preds = %2
  tail call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 41, ptr noundef nonnull @__PRETTY_FUNCTION__.px_histogram_rgb) #7
  unreachable

6:                                                ; preds = %2
  %7 = getelementptr inbounds i8, ptr %0, i64 16
  %8 = load i32, ptr %7, align 8, !tbaa !5
  %9 = icmp eq i32 %8, 3
  br i1 %9, label %11, label %10

10:                                               ; preds = %6
  tail call void @__assert_fail(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.1, i32 noundef 44, ptr noundef nonnull @__PRETTY_FUNCTION__.px_histogram_rgb) #7
  unreachable

11:                                               ; preds = %6
  %12 = getelementptr inbounds i8, ptr %0, i64 12
  %13 = load i32, ptr %12, align 4, !tbaa !11
  %14 = getelementptr inbounds i8, ptr %0, i64 8
  %15 = load i32, ptr %14, align 8, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 1024, ptr nonnull %3) #6
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(1024) %3, i8 0, i64 1024, i1 false)
  switch i32 %1, label %.critedge [
    i32 0, label %.preheader
    i32 1, label %47
    i32 2, label %41
    i32 3, label %42
  ]

.preheader:                                       ; preds = %11
  %16 = icmp sgt i32 %13, 0
  br i1 %16, label %.lr.ph54, label %.loopexit

.lr.ph54:                                         ; preds = %.preheader
  %17 = load ptr, ptr %0, align 8, !tbaa !13
  %18 = icmp sgt i32 %15, 0
  br i1 %18, label %.lr.ph.us55.preheader, label %.loopexit

.lr.ph.us55.preheader:                            ; preds = %.lr.ph54
  %19 = getelementptr inbounds i8, ptr %0, i64 20
  %20 = load i32, ptr %19, align 4, !tbaa !14
  %21 = sext i32 %20 to i64
  %wide.trip.count66 = zext nneg i32 %13 to i64
  br label %.lr.ph.us55

.lr.ph.us55:                                      ; preds = %.lr.ph.us55.preheader, %._crit_edge.us56
  %indvars.iv63 = phi i64 [ 0, %.lr.ph.us55.preheader ], [ %indvars.iv.next64, %._crit_edge.us56 ]
  %22 = mul nsw i64 %indvars.iv63, %21
  %23 = getelementptr inbounds i8, ptr %17, i64 %22
  br label %24

24:                                               ; preds = %.lr.ph.us55, %24
  %.04252.us = phi i32 [ 0, %.lr.ph.us55 ], [ %40, %24 ]
  %.04351.us = phi ptr [ %23, %.lr.ph.us55 ], [ %39, %24 ]
  %25 = load i8, ptr %.04351.us, align 1, !tbaa !15
  %26 = zext i8 %25 to i16
  %27 = getelementptr inbounds i8, ptr %.04351.us, i64 1
  %28 = load i8, ptr %27, align 1, !tbaa !15
  %29 = zext i8 %28 to i16
  %30 = add nuw nsw i16 %29, %26
  %31 = getelementptr inbounds i8, ptr %.04351.us, i64 2
  %32 = load i8, ptr %31, align 1, !tbaa !15
  %33 = zext i8 %32 to i16
  %.lhs.trunc.us = add nuw nsw i16 %30, %33
  %34 = udiv i16 %.lhs.trunc.us, 3
  %35 = zext nneg i16 %34 to i64
  %36 = getelementptr inbounds [256 x i32], ptr %3, i64 0, i64 %35
  %37 = load i32, ptr %36, align 4, !tbaa !16
  %38 = add nsw i32 %37, 1
  store i32 %38, ptr %36, align 4, !tbaa !16
  %39 = getelementptr inbounds i8, ptr %.04351.us, i64 3
  %40 = add nuw nsw i32 %.04252.us, 1
  %exitcond62.not = icmp eq i32 %40, %15
  br i1 %exitcond62.not, label %._crit_edge.us56, label %24, !llvm.loop !17

._crit_edge.us56:                                 ; preds = %24
  %indvars.iv.next64 = add nuw nsw i64 %indvars.iv63, 1
  %exitcond67.not = icmp eq i64 %indvars.iv.next64, %wide.trip.count66
  br i1 %exitcond67.not, label %.loopexit, label %.lr.ph.us55, !llvm.loop !19

41:                                               ; preds = %11
  br label %47

42:                                               ; preds = %11
  br label %47

.critedge:                                        ; preds = %11
  %43 = load ptr, ptr @stderr, align 8, !tbaa !20
  %44 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %43, ptr noundef nonnull @.str.3, i32 noundef %1) #8
  %45 = load ptr, ptr @stderr, align 8, !tbaa !20
  %46 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %45, ptr noundef nonnull @.str.4) #8
  br label %87

47:                                               ; preds = %11, %41, %42
  %.040 = phi i64 [ 1, %41 ], [ 2, %42 ], [ 0, %11 ]
  %48 = icmp sgt i32 %13, 0
  br i1 %48, label %.lr.ph50, label %.loopexit

.lr.ph50:                                         ; preds = %47
  %49 = load ptr, ptr %0, align 8, !tbaa !13
  %invariant.gep = getelementptr i8, ptr %49, i64 %.040
  %50 = icmp sgt i32 %15, 0
  br i1 %50, label %.lr.ph.us.preheader, label %.loopexit

.lr.ph.us.preheader:                              ; preds = %.lr.ph50
  %51 = getelementptr inbounds i8, ptr %0, i64 20
  %52 = load i32, ptr %51, align 4, !tbaa !14
  %53 = sext i32 %52 to i64
  %wide.trip.count = zext nneg i32 %13 to i64
  %xtraiter = and i32 %15, 3
  %54 = icmp ult i32 %15, 4
  %unroll_iter = and i32 %15, 2147483644
  %lcmp.mod.not = icmp eq i32 %xtraiter, 0
  br label %.lr.ph.us

.lr.ph.us:                                        ; preds = %.lr.ph.us.preheader, %._crit_edge.us
  %indvars.iv = phi i64 [ 0, %.lr.ph.us.preheader ], [ %indvars.iv.next, %._crit_edge.us ]
  %55 = mul nsw i64 %indvars.iv, %53
  %gep.us = getelementptr i8, ptr %invariant.gep, i64 %55
  br i1 %54, label %._crit_edge.us.unr-lcssa, label %.lr.ph.us.new

.lr.ph.us.new:                                    ; preds = %.lr.ph.us, %.lr.ph.us.new
  %.03846.us = phi ptr [ %79, %.lr.ph.us.new ], [ %gep.us, %.lr.ph.us ]
  %niter = phi i32 [ %niter.next.3, %.lr.ph.us.new ], [ 0, %.lr.ph.us ]
  %56 = load i8, ptr %.03846.us, align 1, !tbaa !15
  %57 = zext i8 %56 to i64
  %58 = getelementptr inbounds [256 x i32], ptr %3, i64 0, i64 %57
  %59 = load i32, ptr %58, align 4, !tbaa !16
  %60 = add nsw i32 %59, 1
  store i32 %60, ptr %58, align 4, !tbaa !16
  %61 = getelementptr inbounds i8, ptr %.03846.us, i64 3
  %62 = load i8, ptr %61, align 1, !tbaa !15
  %63 = zext i8 %62 to i64
  %64 = getelementptr inbounds [256 x i32], ptr %3, i64 0, i64 %63
  %65 = load i32, ptr %64, align 4, !tbaa !16
  %66 = add nsw i32 %65, 1
  store i32 %66, ptr %64, align 4, !tbaa !16
  %67 = getelementptr inbounds i8, ptr %.03846.us, i64 6
  %68 = load i8, ptr %67, align 1, !tbaa !15
  %69 = zext i8 %68 to i64
  %70 = getelementptr inbounds [256 x i32], ptr %3, i64 0, i64 %69
  %71 = load i32, ptr %70, align 4, !tbaa !16
  %72 = add nsw i32 %71, 1
  store i32 %72, ptr %70, align 4, !tbaa !16
  %73 = getelementptr inbounds i8, ptr %.03846.us, i64 9
  %74 = load i8, ptr %73, align 1, !tbaa !15
  %75 = zext i8 %74 to i64
  %76 = getelementptr inbounds [256 x i32], ptr %3, i64 0, i64 %75
  %77 = load i32, ptr %76, align 4, !tbaa !16
  %78 = add nsw i32 %77, 1
  store i32 %78, ptr %76, align 4, !tbaa !16
  %79 = getelementptr inbounds i8, ptr %.03846.us, i64 12
  %niter.next.3 = add i32 %niter, 4
  %niter.ncmp.3 = icmp eq i32 %niter.next.3, %unroll_iter
  br i1 %niter.ncmp.3, label %._crit_edge.us.unr-lcssa, label %.lr.ph.us.new, !llvm.loop !21

._crit_edge.us.unr-lcssa:                         ; preds = %.lr.ph.us.new, %.lr.ph.us
  %.03846.us.unr = phi ptr [ %gep.us, %.lr.ph.us ], [ %79, %.lr.ph.us.new ]
  br i1 %lcmp.mod.not, label %._crit_edge.us, label %.epil.preheader

.epil.preheader:                                  ; preds = %._crit_edge.us.unr-lcssa, %.epil.preheader
  %.03846.us.epil = phi ptr [ %85, %.epil.preheader ], [ %.03846.us.unr, %._crit_edge.us.unr-lcssa ]
  %epil.iter = phi i32 [ %epil.iter.next, %.epil.preheader ], [ 0, %._crit_edge.us.unr-lcssa ]
  %80 = load i8, ptr %.03846.us.epil, align 1, !tbaa !15
  %81 = zext i8 %80 to i64
  %82 = getelementptr inbounds [256 x i32], ptr %3, i64 0, i64 %81
  %83 = load i32, ptr %82, align 4, !tbaa !16
  %84 = add nsw i32 %83, 1
  store i32 %84, ptr %82, align 4, !tbaa !16
  %85 = getelementptr inbounds i8, ptr %.03846.us.epil, i64 3
  %epil.iter.next = add i32 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i32 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %._crit_edge.us, label %.epil.preheader, !llvm.loop !22

._crit_edge.us:                                   ; preds = %.epil.preheader, %._crit_edge.us.unr-lcssa
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond61.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond61.not, label %.loopexit, label %.lr.ph.us, !llvm.loop !24

.loopexit:                                        ; preds = %._crit_edge.us, %._crit_edge.us56, %.lr.ph50, %.lr.ph54, %47, %.preheader
  %86 = call ptr @histogram_lut_to_image(ptr noundef nonnull %3)
  br label %87

87:                                               ; preds = %.critedge, %.loopexit
  %.1 = phi ptr [ %86, %.loopexit ], [ null, %.critedge ]
  call void @llvm.lifetime.end.p0(i64 1024, ptr nonnull %3) #6
  ret ptr %.1
}

declare zeroext i1 @px_is_valid_rgb_image(ptr noundef) local_unnamed_addr #1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #2

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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #4

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

; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #5

; Function Attrs: nounwind uwtable
declare hidden ptr @histogram_lut_to_image(ptr noundef) local_unnamed_addr #0

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 = { "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 = { noreturn 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 #3 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #6 = { nounwind }
attributes #7 = { noreturn nounwind }
attributes #8 = { cold 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 = !{!"px_image_t", !7, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!6, !10, i64 12}
!12 = !{!6, !10, i64 8}
!13 = !{!6, !7, i64 0}
!14 = !{!6, !10, i64 20}
!15 = !{!8, !8, i64 0}
!16 = !{!10, !10, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = distinct !{!19, !18}
!20 = !{!7, !7, i64 0}
!21 = distinct !{!21, !18}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.unroll.disable"}
!24 = distinct !{!24, !18}


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