; LLVM IR from aap/librw :: src/image.ll (ZN2rw5Image11unpalettizeEb)

; 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.rw::Image" = type { i32, i32, i32, i32, i32, i32, ptr, ptr }

@.str.2 = external hidden unnamed_addr constant [57 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [14 x i8], align 1
@__PRETTY_FUNCTION__._ZN2rw5Image11unpalettizeEb = external hidden unnamed_addr constant [34 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [73 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
declare dso_local void @_ZN2rw5Image4freeEv(ptr noundef nonnull align 8 dereferenceable(40)) #1 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZN2rw14mustmalloc_LOCEmjPKc(i64 noundef, i32 noundef, ptr noundef) #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN2rw5Image9setPixelsEPh(ptr noundef nonnull align 8 dereferenceable(40), ptr noundef) #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN2rw5Image8hasAlphaEv(ptr noundef nonnull align 8 dereferenceable(40)) #3 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN2rw5Image11unpalettizeEb(ptr noundef nonnull align 8 dereferenceable(40) %0, i1 noundef zeroext %1) #1 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca i8, align 1
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  %15 = zext i1 %1 to i8
  store i8 %15, ptr %4, align 1, !tbaa !9
  %16 = load ptr, ptr %3, align 8
  %17 = getelementptr inbounds %"struct.rw::Image", ptr %16, i32 0, i32 3
  %18 = load i32, ptr %17, align 4, !tbaa !11
  %19 = icmp sgt i32 %18, 8
  br i1 %19, label %20, label %21

20:                                               ; preds = %2
  br label %163

21:                                               ; preds = %2
  %22 = getelementptr inbounds %"struct.rw::Image", ptr %16, i32 0, i32 6
  %23 = load ptr, ptr %22, align 8, !tbaa !14
  %24 = icmp ne ptr %23, null
  br i1 %24, label %25, label %26

25:                                               ; preds = %21
  br label %28

26:                                               ; preds = %21
  call void @__assert_fail(ptr noundef @.str.6, ptr noundef @.str.2, i32 noundef 709, ptr noundef @__PRETTY_FUNCTION__._ZN2rw5Image11unpalettizeEb) #5
  unreachable

27:                                               ; No predecessors!
  br label %28

28:                                               ; preds = %27, %25
  %29 = getelementptr inbounds %"struct.rw::Image", ptr %16, i32 0, i32 7
  %30 = load ptr, ptr %29, align 8, !tbaa !15
  %31 = icmp ne ptr %30, null
  br i1 %31, label %32, label %33

32:                                               ; preds = %28
  br label %35

33:                                               ; preds = %28
  call void @__assert_fail(ptr noundef @.str.7, ptr noundef @.str.2, i32 noundef 710, ptr noundef @__PRETTY_FUNCTION__._ZN2rw5Image11unpalettizeEb) #5
  unreachable

34:                                               ; No predecessors!
  br label %35

35:                                               ; preds = %34, %32
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #6
  %36 = load i8, ptr %4, align 1, !tbaa !9, !range !16, !noundef !17
  %37 = trunc i8 %36 to i1
  br i1 %37, label %41, label %38

38:                                               ; preds = %35
  %39 = call noundef i32 @_ZN2rw5Image8hasAlphaEv(ptr noundef nonnull align 8 dereferenceable(40) %16)
  %40 = icmp ne i32 %39, 0
  br label %41

41:                                               ; preds = %38, %35
  %42 = phi i1 [ true, %35 ], [ %40, %38 ]
  %43 = zext i1 %42 to i64
  %44 = select i1 %42, i32 32, i32 24
  store i32 %44, ptr %5, align 4, !tbaa !18
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  %45 = getelementptr inbounds %"struct.rw::Image", ptr %16, i32 0, i32 1
  %46 = load i32, ptr %45, align 4, !tbaa !19
  %47 = load i32, ptr %5, align 4, !tbaa !18
  %48 = mul nsw i32 %46, %47
  %49 = sdiv i32 %48, 8
  store i32 %49, ptr %6, align 4, !tbaa !18
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #6
  %50 = load i32, ptr %6, align 4, !tbaa !18
  %51 = getelementptr inbounds %"struct.rw::Image", ptr %16, i32 0, i32 2
  %52 = load i32, ptr %51, align 8, !tbaa !20
  %53 = mul nsw i32 %50, %52
  %54 = sext i32 %53 to i64
  %55 = mul i64 %54, 1
  %56 = call noundef ptr @_ZN2rw14mustmalloc_LOCEmjPKc(i64 noundef %55, i32 noundef 196632, ptr noundef @.str.11)
  store ptr %56, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #6
  %57 = getelementptr inbounds %"struct.rw::Image", ptr %16, i32 0, i32 6
  %58 = load ptr, ptr %57, align 8, !tbaa !14
  store ptr %58, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #6
  %59 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %59, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #6
  store i32 0, ptr %12, align 4, !tbaa !18
  br label %60

60:                                               ; preds = %145, %41
  %61 = load i32, ptr %12, align 4, !tbaa !18
  %62 = getelementptr inbounds %"struct.rw::Image", ptr %16, i32 0, i32 2
  %63 = load i32, ptr %62, align 8, !tbaa !20
  %64 = icmp slt i32 %61, %63
  br i1 %64, label %66, label %65

65:                                               ; preds = %60
  store i32 2, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #6
  br label %148

66:                                               ; preds = %60
  %67 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %67, ptr %10, align 8, !tbaa !5
  %68 = load ptr, ptr %9, align 8, !tbaa !5
  store ptr %68, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #6
  store i32 0, ptr %14, align 4, !tbaa !18
  br label %69

69:                                               ; preds = %132, %66
  %70 = load i32, ptr %14, align 4, !tbaa !18
  %71 = getelementptr inbounds %"struct.rw::Image", ptr %16, i32 0, i32 1
  %72 = load i32, ptr %71, align 4, !tbaa !19
  %73 = icmp slt i32 %70, %72
  br i1 %73, label %75, label %74

74:                                               ; preds = %69
  store i32 5, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #6
  br label %135

75:                                               ; preds = %69
  %76 = getelementptr inbounds %"struct.rw::Image", ptr %16, i32 0, i32 7
  %77 = load ptr, ptr %76, align 8, !tbaa !15
  %78 = load ptr, ptr %10, align 8, !tbaa !5
  %79 = load i8, ptr %78, align 1, !tbaa !21
  %80 = zext i8 %79 to i32
  %81 = mul nsw i32 %80, 4
  %82 = add nsw i32 %81, 0
  %83 = sext i32 %82 to i64
  %84 = getelementptr inbounds i8, ptr %77, i64 %83
  %85 = load i8, ptr %84, align 1, !tbaa !21
  %86 = load ptr, ptr %11, align 8, !tbaa !5
  %87 = getelementptr inbounds i8, ptr %86, i64 0
  store i8 %85, ptr %87, align 1, !tbaa !21
  %88 = getelementptr inbounds %"struct.rw::Image", ptr %16, i32 0, i32 7
  %89 = load ptr, ptr %88, align 8, !tbaa !15
  %90 = load ptr, ptr %10, align 8, !tbaa !5
  %91 = load i8, ptr %90, align 1, !tbaa !21
  %92 = zext i8 %91 to i32
  %93 = mul nsw i32 %92, 4
  %94 = add nsw i32 %93, 1
  %95 = sext i32 %94 to i64
  %96 = getelementptr inbounds i8, ptr %89, i64 %95
  %97 = load i8, ptr %96, align 1, !tbaa !21
  %98 = load ptr, ptr %11, align 8, !tbaa !5
  %99 = getelementptr inbounds i8, ptr %98, i64 1
  store i8 %97, ptr %99, align 1, !tbaa !21
  %100 = getelementptr inbounds %"struct.rw::Image", ptr %16, i32 0, i32 7
  %101 = load ptr, ptr %100, align 8, !tbaa !15
  %102 = load ptr, ptr %10, align 8, !tbaa !5
  %103 = load i8, ptr %102, align 1, !tbaa !21
  %104 = zext i8 %103 to i32
  %105 = mul nsw i32 %104, 4
  %106 = add nsw i32 %105, 2
  %107 = sext i32 %106 to i64
  %108 = getelementptr inbounds i8, ptr %101, i64 %107
  %109 = load i8, ptr %108, align 1, !tbaa !21
  %110 = load ptr, ptr %11, align 8, !tbaa !5
  %111 = getelementptr inbounds i8, ptr %110, i64 2
  store i8 %109, ptr %111, align 1, !tbaa !21
  %112 = load ptr, ptr %11, align 8, !tbaa !5
  %113 = getelementptr inbounds i8, ptr %112, i64 3
  store ptr %113, ptr %11, align 8, !tbaa !5
  %114 = load i32, ptr %5, align 4, !tbaa !18
  %115 = icmp eq i32 %114, 32
  br i1 %115, label %116, label %129

116:                                              ; preds = %75
  %117 = getelementptr inbounds %"struct.rw::Image", ptr %16, i32 0, i32 7
  %118 = load ptr, ptr %117, align 8, !tbaa !15
  %119 = load ptr, ptr %10, align 8, !tbaa !5
  %120 = load i8, ptr %119, align 1, !tbaa !21
  %121 = zext i8 %120 to i32
  %122 = mul nsw i32 %121, 4
  %123 = add nsw i32 %122, 3
  %124 = sext i32 %123 to i64
  %125 = getelementptr inbounds i8, ptr %118, i64 %124
  %126 = load i8, ptr %125, align 1, !tbaa !21
  %127 = load ptr, ptr %11, align 8, !tbaa !5
  %128 = getelementptr inbounds i8, ptr %127, i32 1
  store ptr %128, ptr %11, align 8, !tbaa !5
  store i8 %126, ptr %127, align 1, !tbaa !21
  br label %129

129:                                              ; preds = %116, %75
  %130 = load ptr, ptr %10, align 8, !tbaa !5
  %131 = getelementptr inbounds i8, ptr %130, i32 1
  store ptr %131, ptr %10, align 8, !tbaa !5
  br label %132

132:                                              ; preds = %129
  %133 = load i32, ptr %14, align 4, !tbaa !18
  %134 = add nsw i32 %133, 1
  store i32 %134, ptr %14, align 4, !tbaa !18
  br label %69, !llvm.loop !22

135:                                              ; preds = %74
  %136 = getelementptr inbounds %"struct.rw::Image", ptr %16, i32 0, i32 5
  %137 = load i32, ptr %136, align 4, !tbaa !24
  %138 = load ptr, ptr %8, align 8, !tbaa !5
  %139 = sext i32 %137 to i64
  %140 = getelementptr inbounds i8, ptr %138, i64 %139
  store ptr %140, ptr %8, align 8, !tbaa !5
  %141 = load i32, ptr %6, align 4, !tbaa !18
  %142 = load ptr, ptr %9, align 8, !tbaa !5
  %143 = sext i32 %141 to i64
  %144 = getelementptr inbounds i8, ptr %142, i64 %143
  store ptr %144, ptr %9, align 8, !tbaa !5
  br label %145

145:                                              ; preds = %135
  %146 = load i32, ptr %12, align 4, !tbaa !18
  %147 = add nsw i32 %146, 1
  store i32 %147, ptr %12, align 4, !tbaa !18
  br label %60, !llvm.loop !25

148:                                              ; preds = %65
  call void @_ZN2rw5Image4freeEv(ptr noundef nonnull align 8 dereferenceable(40) %16)
  %149 = load i32, ptr %5, align 4, !tbaa !18
  %150 = getelementptr inbounds %"struct.rw::Image", ptr %16, i32 0, i32 3
  store i32 %149, ptr %150, align 4, !tbaa !11
  %151 = load i32, ptr %5, align 4, !tbaa !18
  %152 = icmp slt i32 %151, 8
  br i1 %152, label %153, label %154

153:                                              ; preds = %148
  br label %157

154:                                              ; preds = %148
  %155 = load i32, ptr %5, align 4, !tbaa !18
  %156 = sdiv i32 %155, 8
  br label %157

157:                                              ; preds = %154, %153
  %158 = phi i32 [ 1, %153 ], [ %156, %154 ]
  %159 = getelementptr inbounds %"struct.rw::Image", ptr %16, i32 0, i32 4
  store i32 %158, ptr %159, align 8, !tbaa !26
  %160 = load i32, ptr %6, align 4, !tbaa !18
  %161 = getelementptr inbounds %"struct.rw::Image", ptr %16, i32 0, i32 5
  store i32 %160, ptr %161, align 4, !tbaa !24
  %162 = load ptr, ptr %7, align 8, !tbaa !5
  call void @_ZN2rw5Image9setPixelsEPh(ptr noundef nonnull align 8 dereferenceable(40) %16, ptr noundef %162)
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #6
  br label %163

163:                                              ; preds = %157, %20
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { inlinehint mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { 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 #5 = { noreturn nounwind }
attributes #6 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"bool", !7, i64 0}
!11 = !{!12, !13, i64 12}
!12 = !{!"_ZTSN2rw5ImageE", !13, i64 0, !13, i64 4, !13, i64 8, !13, i64 12, !13, i64 16, !13, i64 20, !6, i64 24, !6, i64 32}
!13 = !{!"int", !7, i64 0}
!14 = !{!12, !6, i64 24}
!15 = !{!12, !6, i64 32}
!16 = !{i8 0, i8 2}
!17 = !{}
!18 = !{!13, !13, i64 0}
!19 = !{!12, !13, i64 4}
!20 = !{!12, !13, i64 8}
!21 = !{!7, !7, i64 0}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.mustprogress"}
!24 = !{!12, !13, i64 20}
!25 = distinct !{!25, !23}
!26 = !{!12, !13, i64 16}


; 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.2 = external hidden unnamed_addr constant [57 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [14 x i8], align 1
@__PRETTY_FUNCTION__._ZN2rw5Image11unpalettizeEb = external hidden unnamed_addr constant [34 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [73 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN2rw5Image4freeEv(ptr noundef nonnull align 8 dereferenceable(40)) local_unnamed_addr #0 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZN2rw14mustmalloc_LOCEmjPKc(i64 noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN2rw5Image9setPixelsEPh(ptr noundef nonnull align 8 dereferenceable(40), ptr noundef) local_unnamed_addr #2 align 2

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN2rw5Image11unpalettizeEb(ptr noundef nonnull align 8 dereferenceable(40) %0, i1 noundef zeroext %1) local_unnamed_addr #0 align 2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 12
  %4 = load i32, ptr %3, align 4, !tbaa !5
  %5 = icmp sgt i32 %4, 8
  br i1 %5, label %111, label %6

6:                                                ; preds = %2
  %7 = getelementptr inbounds i8, ptr %0, i64 24
  %8 = load ptr, ptr %7, align 8, !tbaa !11
  %.not = icmp eq ptr %8, null
  br i1 %.not, label %9, label %10

9:                                                ; preds = %6
  tail call void @__assert_fail(ptr noundef nonnull @.str.6, ptr noundef nonnull @.str.2, i32 noundef 709, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN2rw5Image11unpalettizeEb) #4
  unreachable

10:                                               ; preds = %6
  %11 = getelementptr inbounds i8, ptr %0, i64 32
  %12 = load ptr, ptr %11, align 8, !tbaa !12
  %.not34 = icmp eq ptr %12, null
  br i1 %.not34, label %13, label %14

13:                                               ; preds = %10
  tail call void @__assert_fail(ptr noundef nonnull @.str.7, ptr noundef nonnull @.str.2, i32 noundef 710, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN2rw5Image11unpalettizeEb) #4
  unreachable

14:                                               ; preds = %10
  br i1 %1, label %.thread, label %15

15:                                               ; preds = %14
  %16 = tail call noundef i32 @_ZN2rw5Image8hasAlphaEv(ptr noundef nonnull align 8 dereferenceable(40) %0)
  %17 = icmp ne i32 %16, 0
  %spec.select35 = select i1 %17, i32 32, i32 24
  br label %.thread

.thread:                                          ; preds = %15, %14
  %18 = phi i1 [ true, %14 ], [ %17, %15 ]
  %19 = phi i32 [ 32, %14 ], [ %spec.select35, %15 ]
  %20 = getelementptr inbounds i8, ptr %0, i64 4
  %21 = load i32, ptr %20, align 4, !tbaa !13
  %22 = mul nsw i32 %21, %19
  %23 = ashr exact i32 %22, 3
  %24 = getelementptr inbounds i8, ptr %0, i64 8
  %25 = load i32, ptr %24, align 8, !tbaa !14
  %26 = mul nsw i32 %23, %25
  %27 = sext i32 %26 to i64
  %28 = tail call noundef ptr @_ZN2rw14mustmalloc_LOCEmjPKc(i64 noundef %27, i32 noundef 196632, ptr noundef nonnull @.str.11)
  %29 = load i32, ptr %24, align 8, !tbaa !14
  %30 = icmp sgt i32 %29, 0
  br i1 %30, label %.preheader.lr.ph, label %._crit_edge44

.preheader.lr.ph:                                 ; preds = %.thread
  %31 = getelementptr inbounds i8, ptr %0, i64 20
  %32 = sext i32 %23 to i64
  %33 = load i32, ptr %20, align 4, !tbaa !13
  %34 = icmp sgt i32 %33, 0
  br i1 %34, label %.preheader.preheader, label %._crit_edge44

.preheader.preheader:                             ; preds = %.preheader.lr.ph
  %35 = load ptr, ptr %7, align 8, !tbaa !11
  br label %.preheader

.preheader:                                       ; preds = %.preheader.preheader, %._crit_edge
  %36 = phi i32 [ %76, %._crit_edge ], [ %33, %.preheader.preheader ]
  %.02943 = phi i32 [ %81, %._crit_edge ], [ 0, %.preheader.preheader ]
  %.03241 = phi ptr [ %80, %._crit_edge ], [ %28, %.preheader.preheader ]
  %.03339 = phi ptr [ %79, %._crit_edge ], [ %35, %.preheader.preheader ]
  %37 = icmp sgt i32 %36, 0
  br i1 %37, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %.preheader
  br i1 %18, label %.lr.ph.split.us, label %.lr.ph.split

.lr.ph.split.us:                                  ; preds = %.lr.ph, %.lr.ph.split.us
  %.038.us = phi i32 [ %70, %.lr.ph.split.us ], [ 0, %.lr.ph ]
  %.03037.us = phi ptr [ %68, %.lr.ph.split.us ], [ %.03241, %.lr.ph ]
  %.03136.us = phi ptr [ %69, %.lr.ph.split.us ], [ %.03339, %.lr.ph ]
  %38 = load ptr, ptr %11, align 8, !tbaa !12
  %39 = load i8, ptr %.03136.us, align 1, !tbaa !15
  %40 = zext i8 %39 to i64
  %41 = shl nuw nsw i64 %40, 2
  %42 = getelementptr inbounds i8, ptr %38, i64 %41
  %43 = load i8, ptr %42, align 1, !tbaa !15
  store i8 %43, ptr %.03037.us, align 1, !tbaa !15
  %44 = load ptr, ptr %11, align 8, !tbaa !12
  %45 = load i8, ptr %.03136.us, align 1, !tbaa !15
  %46 = zext i8 %45 to i64
  %47 = shl nuw nsw i64 %46, 2
  %48 = or disjoint i64 %47, 1
  %49 = getelementptr inbounds i8, ptr %44, i64 %48
  %50 = load i8, ptr %49, align 1, !tbaa !15
  %51 = getelementptr inbounds i8, ptr %.03037.us, i64 1
  store i8 %50, ptr %51, align 1, !tbaa !15
  %52 = load ptr, ptr %11, align 8, !tbaa !12
  %53 = load i8, ptr %.03136.us, align 1, !tbaa !15
  %54 = zext i8 %53 to i64
  %55 = shl nuw nsw i64 %54, 2
  %56 = or disjoint i64 %55, 2
  %57 = getelementptr inbounds i8, ptr %52, i64 %56
  %58 = load i8, ptr %57, align 1, !tbaa !15
  %59 = getelementptr inbounds i8, ptr %.03037.us, i64 2
  store i8 %58, ptr %59, align 1, !tbaa !15
  %60 = getelementptr inbounds i8, ptr %.03037.us, i64 3
  %61 = load ptr, ptr %11, align 8, !tbaa !12
  %62 = load i8, ptr %.03136.us, align 1, !tbaa !15
  %63 = zext i8 %62 to i64
  %64 = shl nuw nsw i64 %63, 2
  %65 = or disjoint i64 %64, 3
  %66 = getelementptr inbounds i8, ptr %61, i64 %65
  %67 = load i8, ptr %66, align 1, !tbaa !15
  %68 = getelementptr inbounds i8, ptr %.03037.us, i64 4
  store i8 %67, ptr %60, align 1, !tbaa !15
  %69 = getelementptr inbounds i8, ptr %.03136.us, i64 1
  %70 = add nuw nsw i32 %.038.us, 1
  %71 = load i32, ptr %20, align 4, !tbaa !13
  %72 = icmp slt i32 %70, %71
  br i1 %72, label %.lr.ph.split.us, label %._crit_edge, !llvm.loop !16

._crit_edge44:                                    ; preds = %._crit_edge, %.preheader.lr.ph, %.thread
  tail call void @_ZN2rw5Image4freeEv(ptr noundef nonnull align 8 dereferenceable(40) %0)
  store i32 %19, ptr %3, align 4, !tbaa !5
  %73 = lshr exact i32 %19, 3
  %74 = getelementptr inbounds i8, ptr %0, i64 16
  store i32 %73, ptr %74, align 8, !tbaa !18
  %75 = getelementptr inbounds i8, ptr %0, i64 20
  store i32 %23, ptr %75, align 4, !tbaa !19
  tail call void @_ZN2rw5Image9setPixelsEPh(ptr noundef nonnull align 8 dereferenceable(40) %0, ptr noundef %28)
  br label %111

._crit_edge:                                      ; preds = %.lr.ph.split, %.lr.ph.split.us, %.preheader
  %76 = phi i32 [ %36, %.preheader ], [ %71, %.lr.ph.split.us ], [ %109, %.lr.ph.split ]
  %77 = load i32, ptr %31, align 4, !tbaa !19
  %78 = sext i32 %77 to i64
  %79 = getelementptr inbounds i8, ptr %.03339, i64 %78
  %80 = getelementptr inbounds i8, ptr %.03241, i64 %32
  %81 = add nuw nsw i32 %.02943, 1
  %82 = load i32, ptr %24, align 8, !tbaa !14
  %83 = icmp slt i32 %81, %82
  br i1 %83, label %.preheader, label %._crit_edge44, !llvm.loop !20

.lr.ph.split:                                     ; preds = %.lr.ph, %.lr.ph.split
  %.038 = phi i32 [ %108, %.lr.ph.split ], [ 0, %.lr.ph ]
  %.03037 = phi ptr [ %106, %.lr.ph.split ], [ %.03241, %.lr.ph ]
  %.03136 = phi ptr [ %107, %.lr.ph.split ], [ %.03339, %.lr.ph ]
  %84 = load ptr, ptr %11, align 8, !tbaa !12
  %85 = load i8, ptr %.03136, align 1, !tbaa !15
  %86 = zext i8 %85 to i64
  %87 = shl nuw nsw i64 %86, 2
  %88 = getelementptr inbounds i8, ptr %84, i64 %87
  %89 = load i8, ptr %88, align 1, !tbaa !15
  store i8 %89, ptr %.03037, align 1, !tbaa !15
  %90 = load ptr, ptr %11, align 8, !tbaa !12
  %91 = load i8, ptr %.03136, align 1, !tbaa !15
  %92 = zext i8 %91 to i64
  %93 = shl nuw nsw i64 %92, 2
  %94 = or disjoint i64 %93, 1
  %95 = getelementptr inbounds i8, ptr %90, i64 %94
  %96 = load i8, ptr %95, align 1, !tbaa !15
  %97 = getelementptr inbounds i8, ptr %.03037, i64 1
  store i8 %96, ptr %97, align 1, !tbaa !15
  %98 = load ptr, ptr %11, align 8, !tbaa !12
  %99 = load i8, ptr %.03136, align 1, !tbaa !15
  %100 = zext i8 %99 to i64
  %101 = shl nuw nsw i64 %100, 2
  %102 = or disjoint i64 %101, 2
  %103 = getelementptr inbounds i8, ptr %98, i64 %102
  %104 = load i8, ptr %103, align 1, !tbaa !15
  %105 = getelementptr inbounds i8, ptr %.03037, i64 2
  store i8 %104, ptr %105, align 1, !tbaa !15
  %106 = getelementptr inbounds i8, ptr %.03037, i64 3
  %107 = getelementptr inbounds i8, ptr %.03136, i64 1
  %108 = add nuw nsw i32 %.038, 1
  %109 = load i32, ptr %20, align 4, !tbaa !13
  %110 = icmp slt i32 %108, %109
  br i1 %110, label %.lr.ph.split, label %._crit_edge, !llvm.loop !16

111:                                              ; preds = %2, %._crit_edge44
  ret void
}

attributes #0 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { inlinehint mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { 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 #4 = { noreturn 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, !7, i64 12}
!6 = !{!"_ZTSN2rw5ImageE", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20, !10, i64 24, !10, i64 32}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !10, i64 24}
!12 = !{!6, !10, i64 32}
!13 = !{!6, !7, i64 4}
!14 = !{!6, !7, i64 8}
!15 = !{!8, !8, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = !{!6, !7, i64 16}
!19 = !{!6, !7, i64 20}
!20 = distinct !{!20, !17, !21}
!21 = !{!"llvm.loop.unswitch.partial.disable"}


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