; LLVM IR from achilles288/robot-monitor-graphics :: src/base/bitmap.ll (ZNK3rmg6Bitmap4toGAEv)

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

%"class.rmg::Bitmap" = type { i16, i16, i8, ptr }

; 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 nounwind uwtable
declare hidden noundef float @_ZN3rmgL12getLuminanceEhhh(i8 noundef zeroext, i8 noundef zeroext, i8 noundef zeroext) #1

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK3rmg6Bitmap4toGAEv(ptr dead_on_unwind noalias writable sret(%"class.rmg::Bitmap") align 8 %0, ptr noundef nonnull align 8 dereferenceable(16) %1) #2 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i1, align 1
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca i64, align 8
  store ptr %0, ptr %3, align 8
  store ptr %1, ptr %4, align 8, !tbaa !5
  %14 = load ptr, ptr %4, align 8
  %15 = getelementptr inbounds %"class.rmg::Bitmap", ptr %14, i32 0, i32 2
  %16 = load i8, ptr %15, align 4, !tbaa !9
  %17 = zext i8 %16 to i32
  %18 = icmp eq i32 %17, 2
  br i1 %18, label %19, label %20

19:                                               ; preds = %2
  call void @_ZN3rmg6BitmapC1ERKS0_(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef nonnull align 8 dereferenceable(16) %14)
  br label %151

20:                                               ; preds = %2
  store i1 false, ptr %5, align 1
  %21 = getelementptr inbounds %"class.rmg::Bitmap", ptr %14, i32 0, i32 0
  %22 = load i16, ptr %21, align 8, !tbaa !12
  %23 = getelementptr inbounds %"class.rmg::Bitmap", ptr %14, i32 0, i32 1
  %24 = load i16, ptr %23, align 2, !tbaa !13
  call void @_ZN3rmg6BitmapC1Etth(ptr noundef nonnull align 8 dereferenceable(16) %0, i16 noundef zeroext %22, i16 noundef zeroext %24, i8 noundef zeroext 2)
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %25 = getelementptr inbounds %"class.rmg::Bitmap", ptr %14, i32 0, i32 3
  %26 = load ptr, ptr %25, align 8, !tbaa !14
  store ptr %26, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %27 = getelementptr inbounds %"class.rmg::Bitmap", ptr %0, i32 0, i32 3
  %28 = load ptr, ptr %27, align 8, !tbaa !14
  store ptr %28, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %29 = getelementptr inbounds %"class.rmg::Bitmap", ptr %14, i32 0, i32 0
  %30 = load i16, ptr %29, align 8, !tbaa !12
  %31 = zext i16 %30 to i32
  %32 = getelementptr inbounds %"class.rmg::Bitmap", ptr %14, i32 0, i32 1
  %33 = load i16, ptr %32, align 2, !tbaa !13
  %34 = zext i16 %33 to i32
  %35 = mul nsw i32 %31, %34
  %36 = sext i32 %35 to i64
  store i64 %36, ptr %8, align 8, !tbaa !15
  %37 = getelementptr inbounds %"class.rmg::Bitmap", ptr %14, i32 0, i32 2
  %38 = load i8, ptr %37, align 4, !tbaa !9
  %39 = zext i8 %38 to i32
  %40 = icmp eq i32 %39, 1
  br i1 %40, label %41, label %63

41:                                               ; preds = %20
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  store i64 0, ptr %9, align 8, !tbaa !15
  br label %42

42:                                               ; preds = %59, %41
  %43 = load i64, ptr %9, align 8, !tbaa !15
  %44 = load i64, ptr %8, align 8, !tbaa !15
  %45 = icmp ult i64 %43, %44
  br i1 %45, label %47, label %46

46:                                               ; preds = %42
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  br label %62

47:                                               ; preds = %42
  %48 = load ptr, ptr %6, align 8, !tbaa !5
  %49 = getelementptr inbounds i8, ptr %48, i64 0
  %50 = load i8, ptr %49, align 1, !tbaa !17
  %51 = load ptr, ptr %7, align 8, !tbaa !5
  %52 = getelementptr inbounds i8, ptr %51, i64 0
  store i8 %50, ptr %52, align 1, !tbaa !17
  %53 = load ptr, ptr %7, align 8, !tbaa !5
  %54 = getelementptr inbounds i8, ptr %53, i64 1
  store i8 -1, ptr %54, align 1, !tbaa !17
  %55 = load ptr, ptr %6, align 8, !tbaa !5
  %56 = getelementptr inbounds i8, ptr %55, i64 1
  store ptr %56, ptr %6, align 8, !tbaa !5
  %57 = load ptr, ptr %7, align 8, !tbaa !5
  %58 = getelementptr inbounds i8, ptr %57, i64 2
  store ptr %58, ptr %7, align 8, !tbaa !5
  br label %59

59:                                               ; preds = %47
  %60 = load i64, ptr %9, align 8, !tbaa !15
  %61 = add i64 %60, 1
  store i64 %61, ptr %9, align 8, !tbaa !15
  br label %42, !llvm.loop !18

62:                                               ; preds = %46
  br label %146

63:                                               ; preds = %20
  %64 = getelementptr inbounds %"class.rmg::Bitmap", ptr %14, i32 0, i32 2
  %65 = load i8, ptr %64, align 4, !tbaa !9
  %66 = zext i8 %65 to i32
  %67 = icmp eq i32 %66, 3
  br i1 %67, label %68, label %103

68:                                               ; preds = %63
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  store i64 0, ptr %10, align 8, !tbaa !15
  br label %69

69:                                               ; preds = %95, %68
  %70 = load i64, ptr %10, align 8, !tbaa !15
  %71 = load i64, ptr %8, align 8, !tbaa !15
  %72 = icmp ult i64 %70, %71
  br i1 %72, label %74, label %73

73:                                               ; preds = %69
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  br label %102

74:                                               ; preds = %69
  %75 = load ptr, ptr %6, align 8, !tbaa !5
  %76 = getelementptr inbounds i8, ptr %75, i64 0
  %77 = load i8, ptr %76, align 1, !tbaa !17
  %78 = load ptr, ptr %6, align 8, !tbaa !5
  %79 = getelementptr inbounds i8, ptr %78, i64 1
  %80 = load i8, ptr %79, align 1, !tbaa !17
  %81 = load ptr, ptr %6, align 8, !tbaa !5
  %82 = getelementptr inbounds i8, ptr %81, i64 2
  %83 = load i8, ptr %82, align 1, !tbaa !17
  %84 = invoke noundef float @_ZN3rmgL12getLuminanceEhhh(i8 noundef zeroext %77, i8 noundef zeroext %80, i8 noundef zeroext %83)
          to label %85 unwind label %98

85:                                               ; preds = %74
  %86 = fptoui float %84 to i8
  %87 = load ptr, ptr %7, align 8, !tbaa !5
  %88 = getelementptr inbounds i8, ptr %87, i64 0
  store i8 %86, ptr %88, align 1, !tbaa !17
  %89 = load ptr, ptr %7, align 8, !tbaa !5
  %90 = getelementptr inbounds i8, ptr %89, i64 1
  store i8 -1, ptr %90, align 1, !tbaa !17
  %91 = load ptr, ptr %6, align 8, !tbaa !5
  %92 = getelementptr inbounds i8, ptr %91, i64 3
  store ptr %92, ptr %6, align 8, !tbaa !5
  %93 = load ptr, ptr %7, align 8, !tbaa !5
  %94 = getelementptr inbounds i8, ptr %93, i64 2
  store ptr %94, ptr %7, align 8, !tbaa !5
  br label %95

95:                                               ; preds = %85
  %96 = load i64, ptr %10, align 8, !tbaa !15
  %97 = add i64 %96, 1
  store i64 %97, ptr %10, align 8, !tbaa !15
  br label %69, !llvm.loop !20

98:                                               ; preds = %74
  %99 = landingpad { ptr, i32 }
          cleanup
  %100 = extractvalue { ptr, i32 } %99, 0
  store ptr %100, ptr %11, align 8
  %101 = extractvalue { ptr, i32 } %99, 1
  store i32 %101, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  br label %148

102:                                              ; preds = %73
  br label %145

103:                                              ; preds = %63
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  store i64 0, ptr %13, align 8, !tbaa !15
  br label %104

104:                                              ; preds = %137, %103
  %105 = load i64, ptr %13, align 8, !tbaa !15
  %106 = load i64, ptr %8, align 8, !tbaa !15
  %107 = icmp ult i64 %105, %106
  br i1 %107, label %109, label %108

108:                                              ; preds = %104
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  br label %144

109:                                              ; preds = %104
  %110 = load ptr, ptr %6, align 8, !tbaa !5
  %111 = getelementptr inbounds i8, ptr %110, i64 0
  %112 = load i8, ptr %111, align 1, !tbaa !17
  %113 = load ptr, ptr %6, align 8, !tbaa !5
  %114 = getelementptr inbounds i8, ptr %113, i64 1
  %115 = load i8, ptr %114, align 1, !tbaa !17
  %116 = load ptr, ptr %6, align 8, !tbaa !5
  %117 = getelementptr inbounds i8, ptr %116, i64 2
  %118 = load i8, ptr %117, align 1, !tbaa !17
  %119 = invoke noundef float @_ZN3rmgL12getLuminanceEhhh(i8 noundef zeroext %112, i8 noundef zeroext %115, i8 noundef zeroext %118)
          to label %120 unwind label %140

120:                                              ; preds = %109
  %121 = fptoui float %119 to i8
  %122 = load ptr, ptr %7, align 8, !tbaa !5
  %123 = getelementptr inbounds i8, ptr %122, i64 0
  store i8 %121, ptr %123, align 1, !tbaa !17
  %124 = load ptr, ptr %6, align 8, !tbaa !5
  %125 = getelementptr inbounds i8, ptr %124, i64 3
  %126 = load i8, ptr %125, align 1, !tbaa !17
  %127 = load ptr, ptr %7, align 8, !tbaa !5
  %128 = getelementptr inbounds i8, ptr %127, i64 1
  store i8 %126, ptr %128, align 1, !tbaa !17
  %129 = getelementptr inbounds %"class.rmg::Bitmap", ptr %14, i32 0, i32 2
  %130 = load i8, ptr %129, align 4, !tbaa !9
  %131 = zext i8 %130 to i32
  %132 = load ptr, ptr %6, align 8, !tbaa !5
  %133 = sext i32 %131 to i64
  %134 = getelementptr inbounds i8, ptr %132, i64 %133
  store ptr %134, ptr %6, align 8, !tbaa !5
  %135 = load ptr, ptr %7, align 8, !tbaa !5
  %136 = getelementptr inbounds i8, ptr %135, i64 2
  store ptr %136, ptr %7, align 8, !tbaa !5
  br label %137

137:                                              ; preds = %120
  %138 = load i64, ptr %13, align 8, !tbaa !15
  %139 = add i64 %138, 1
  store i64 %139, ptr %13, align 8, !tbaa !15
  br label %104, !llvm.loop !21

140:                                              ; preds = %109
  %141 = landingpad { ptr, i32 }
          cleanup
  %142 = extractvalue { ptr, i32 } %141, 0
  store ptr %142, ptr %11, align 8
  %143 = extractvalue { ptr, i32 } %141, 1
  store i32 %143, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  br label %148

144:                                              ; preds = %108
  br label %145

145:                                              ; preds = %144, %102
  br label %146

146:                                              ; preds = %145, %62
  store i1 true, ptr %5, align 1
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  %147 = load i1, ptr %5, align 1
  br i1 %147, label %150, label %149

148:                                              ; preds = %140, %98
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @_ZN3rmg6BitmapD1Ev(ptr noundef nonnull align 8 dereferenceable(16) %0) #3
  br label %152

149:                                              ; preds = %146
  call void @_ZN3rmg6BitmapD1Ev(ptr noundef nonnull align 8 dereferenceable(16) %0) #3
  br label %150

150:                                              ; preds = %149, %146
  br label %151

151:                                              ; preds = %150, %19
  ret void

152:                                              ; preds = %148
  %153 = load ptr, ptr %11, align 8
  %154 = load i32, ptr %12, align 4
  %155 = insertvalue { ptr, i32 } poison, ptr %153, 0
  %156 = insertvalue { ptr, i32 } %155, i32 %154, 1
  resume { ptr, i32 } %156
}

declare void @_ZN3rmg6BitmapC1Etth(ptr, i16, i16, i8)

declare void @_ZN3rmg6BitmapD1Ev(ptr)

declare void @_ZN3rmg6BitmapC1ERKS0_(ptr, ptr)

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { mustprogress 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 = { 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, !7, i64 4}
!10 = !{!"_ZTSN3rmg6BitmapE", !11, i64 0, !11, i64 2, !7, i64 4, !6, i64 8}
!11 = !{!"short", !7, i64 0}
!12 = !{!10, !11, i64 0}
!13 = !{!10, !11, i64 2}
!14 = !{!10, !6, i64 8}
!15 = !{!16, !16, i64 0}
!16 = !{!"long", !7, i64 0}
!17 = !{!7, !7, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = distinct !{!20, !19}
!21 = distinct !{!21, !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"

%"class.rmg::Bitmap" = type { i16, i16, i8, ptr }

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef float @_ZN3rmgL12getLuminanceEhhh(i8 noundef zeroext, i8 noundef zeroext, i8 noundef zeroext) local_unnamed_addr #0

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK3rmg6Bitmap4toGAEv(ptr dead_on_unwind noalias writable sret(%"class.rmg::Bitmap") align 8 %0, ptr noundef nonnull align 8 dereferenceable(16) %1) local_unnamed_addr #1 align 2 personality ptr @__gxx_personality_v0 {
  %3 = getelementptr inbounds i8, ptr %1, i64 4
  %4 = load i8, ptr %3, align 4, !tbaa !5
  %5 = icmp eq i8 %4, 2
  br i1 %5, label %6, label %7

6:                                                ; preds = %2
  tail call void @_ZN3rmg6BitmapC1ERKS0_(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef nonnull align 8 dereferenceable(16) %1)
  br label %.loopexit

7:                                                ; preds = %2
  %8 = load i16, ptr %1, align 8, !tbaa !11
  %9 = getelementptr inbounds i8, ptr %1, i64 2
  %10 = load i16, ptr %9, align 2, !tbaa !12
  tail call void @_ZN3rmg6BitmapC1Etth(ptr noundef nonnull align 8 dereferenceable(16) %0, i16 noundef zeroext %8, i16 noundef zeroext %10, i8 noundef zeroext 2)
  %11 = getelementptr inbounds i8, ptr %1, i64 8
  %12 = load ptr, ptr %11, align 8, !tbaa !13
  %13 = getelementptr inbounds i8, ptr %0, i64 8
  %14 = load ptr, ptr %13, align 8, !tbaa !13
  %15 = load i16, ptr %1, align 8, !tbaa !11
  %16 = zext i16 %15 to i64
  %17 = load i16, ptr %9, align 2, !tbaa !12
  %18 = zext i16 %17 to i64
  %19 = mul nuw nsw i64 %18, %16
  %20 = load i8, ptr %3, align 4, !tbaa !5
  %.not53 = icmp eq i64 %19, 0
  switch i8 %20, label %.preheader [
    i8 1, label %.preheader37
    i8 3, label %.preheader39
  ]

.preheader39:                                     ; preds = %7
  br i1 %.not53, label %.loopexit, label %.lr.ph

.preheader37:                                     ; preds = %7
  br i1 %.not53, label %.loopexit, label %.lr.ph47.preheader

.lr.ph47.preheader:                               ; preds = %.preheader37
  %min.iters.check = icmp ult i64 %19, 16
  br i1 %min.iters.check, label %.lr.ph47.preheader71, label %vector.memcheck

.lr.ph47.preheader71:                             ; preds = %middle.block, %vector.memcheck, %.lr.ph47.preheader
  %.03146.ph = phi i64 [ 0, %vector.memcheck ], [ 0, %.lr.ph47.preheader ], [ %n.vec, %middle.block ]
  %.03245.ph = phi ptr [ %14, %vector.memcheck ], [ %14, %.lr.ph47.preheader ], [ %ind.end, %middle.block ]
  %.03344.ph = phi ptr [ %12, %vector.memcheck ], [ %12, %.lr.ph47.preheader ], [ %ind.end64, %middle.block ]
  %xtraiter = and i64 %19, 3
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.lr.ph47.prol.loopexit, label %.lr.ph47.prol

.lr.ph47.prol:                                    ; preds = %.lr.ph47.preheader71, %.lr.ph47.prol
  %.03146.prol = phi i64 [ %25, %.lr.ph47.prol ], [ %.03146.ph, %.lr.ph47.preheader71 ]
  %.03245.prol = phi ptr [ %24, %.lr.ph47.prol ], [ %.03245.ph, %.lr.ph47.preheader71 ]
  %.03344.prol = phi ptr [ %23, %.lr.ph47.prol ], [ %.03344.ph, %.lr.ph47.preheader71 ]
  %prol.iter = phi i64 [ %prol.iter.next, %.lr.ph47.prol ], [ 0, %.lr.ph47.preheader71 ]
  %21 = load i8, ptr %.03344.prol, align 1, !tbaa !14
  store i8 %21, ptr %.03245.prol, align 1, !tbaa !14
  %22 = getelementptr inbounds i8, ptr %.03245.prol, i64 1
  store i8 -1, ptr %22, align 1, !tbaa !14
  %23 = getelementptr inbounds i8, ptr %.03344.prol, i64 1
  %24 = getelementptr inbounds i8, ptr %.03245.prol, i64 2
  %25 = add nuw nsw i64 %.03146.prol, 1
  %prol.iter.next = add i64 %prol.iter, 1
  %prol.iter.cmp.not = icmp eq i64 %prol.iter.next, %xtraiter
  br i1 %prol.iter.cmp.not, label %.lr.ph47.prol.loopexit, label %.lr.ph47.prol, !llvm.loop !15

.lr.ph47.prol.loopexit:                           ; preds = %.lr.ph47.prol, %.lr.ph47.preheader71
  %.03146.unr = phi i64 [ %.03146.ph, %.lr.ph47.preheader71 ], [ %25, %.lr.ph47.prol ]
  %.03245.unr = phi ptr [ %.03245.ph, %.lr.ph47.preheader71 ], [ %24, %.lr.ph47.prol ]
  %.03344.unr = phi ptr [ %.03344.ph, %.lr.ph47.preheader71 ], [ %23, %.lr.ph47.prol ]
  %26 = sub nsw i64 %.03146.ph, %19
  %27 = icmp ugt i64 %26, -4
  br i1 %27, label %.loopexit, label %.lr.ph47

vector.memcheck:                                  ; preds = %.lr.ph47.preheader
  %28 = mul nuw nsw i64 %18, %16
  %29 = shl nuw nsw i64 %28, 1
  %scevgep = getelementptr i8, ptr %14, i64 %29
  %scevgep62 = getelementptr i8, ptr %12, i64 %19
  %bound0 = icmp ult ptr %14, %scevgep62
  %bound1 = icmp ult ptr %12, %scevgep
  %found.conflict = and i1 %bound0, %bound1
  br i1 %found.conflict, label %.lr.ph47.preheader71, label %vector.ph

vector.ph:                                        ; preds = %vector.memcheck
  %n.vec = and i64 %19, 4294967280
  %30 = shl nuw nsw i64 %n.vec, 1
  %ind.end = getelementptr i8, ptr %14, i64 %30
  %ind.end64 = getelementptr i8, ptr %12, i64 %n.vec
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %offset.idx = shl i64 %index, 1
  %31 = or disjoint i64 %offset.idx, 16
  %next.gep = getelementptr i8, ptr %14, i64 %offset.idx
  %next.gep66 = getelementptr i8, ptr %14, i64 %31
  %next.gep67 = getelementptr i8, ptr %12, i64 %index
  %32 = getelementptr i8, ptr %next.gep67, i64 8
  %wide.load = load <8 x i8>, ptr %next.gep67, align 1, !tbaa !14, !alias.scope !17
  %wide.load69 = load <8 x i8>, ptr %32, align 1, !tbaa !14, !alias.scope !17
  %interleaved.vec = shufflevector <8 x i8> %wide.load, <8 x i8> <i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1>, <16 x i32> <i32 0, i32 8, i32 1, i32 9, i32 2, i32 10, i32 3, i32 11, i32 4, i32 12, i32 5, i32 13, i32 6, i32 14, i32 7, i32 15>
  store <16 x i8> %interleaved.vec, ptr %next.gep, align 1, !tbaa !14
  %interleaved.vec70 = shufflevector <8 x i8> %wide.load69, <8 x i8> <i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1>, <16 x i32> <i32 0, i32 8, i32 1, i32 9, i32 2, i32 10, i32 3, i32 11, i32 4, i32 12, i32 5, i32 13, i32 6, i32 14, i32 7, i32 15>
  store <16 x i8> %interleaved.vec70, ptr %next.gep66, align 1, !tbaa !14
  %index.next = add nuw i64 %index, 16
  %33 = icmp eq i64 %index.next, %n.vec
  br i1 %33, label %middle.block, label %vector.body, !llvm.loop !20

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %19, %n.vec
  br i1 %cmp.n, label %.loopexit, label %.lr.ph47.preheader71

.preheader:                                       ; preds = %7
  br i1 %.not53, label %.loopexit, label %.lr.ph51

.lr.ph47:                                         ; preds = %.lr.ph47.prol.loopexit, %.lr.ph47
  %.03146 = phi i64 [ %50, %.lr.ph47 ], [ %.03146.unr, %.lr.ph47.prol.loopexit ]
  %.03245 = phi ptr [ %49, %.lr.ph47 ], [ %.03245.unr, %.lr.ph47.prol.loopexit ]
  %.03344 = phi ptr [ %48, %.lr.ph47 ], [ %.03344.unr, %.lr.ph47.prol.loopexit ]
  %34 = load i8, ptr %.03344, align 1, !tbaa !14
  store i8 %34, ptr %.03245, align 1, !tbaa !14
  %35 = getelementptr inbounds i8, ptr %.03245, i64 1
  store i8 -1, ptr %35, align 1, !tbaa !14
  %36 = getelementptr inbounds i8, ptr %.03344, i64 1
  %37 = getelementptr inbounds i8, ptr %.03245, i64 2
  %38 = load i8, ptr %36, align 1, !tbaa !14
  store i8 %38, ptr %37, align 1, !tbaa !14
  %39 = getelementptr inbounds i8, ptr %.03245, i64 3
  store i8 -1, ptr %39, align 1, !tbaa !14
  %40 = getelementptr inbounds i8, ptr %.03344, i64 2
  %41 = getelementptr inbounds i8, ptr %.03245, i64 4
  %42 = load i8, ptr %40, align 1, !tbaa !14
  store i8 %42, ptr %41, align 1, !tbaa !14
  %43 = getelementptr inbounds i8, ptr %.03245, i64 5
  store i8 -1, ptr %43, align 1, !tbaa !14
  %44 = getelementptr inbounds i8, ptr %.03344, i64 3
  %45 = getelementptr inbounds i8, ptr %.03245, i64 6
  %46 = load i8, ptr %44, align 1, !tbaa !14
  store i8 %46, ptr %45, align 1, !tbaa !14
  %47 = getelementptr inbounds i8, ptr %.03245, i64 7
  store i8 -1, ptr %47, align 1, !tbaa !14
  %48 = getelementptr inbounds i8, ptr %.03344, i64 4
  %49 = getelementptr inbounds i8, ptr %.03245, i64 8
  %50 = add nuw nsw i64 %.03146, 4
  %exitcond56.not.3 = icmp eq i64 %50, %19
  br i1 %exitcond56.not.3, label %.loopexit, label %.lr.ph47, !llvm.loop !24

.lr.ph:                                           ; preds = %.preheader39, %.lr.ph
  %.03043 = phi i64 [ %61, %.lr.ph ], [ 0, %.preheader39 ]
  %.142 = phi ptr [ %60, %.lr.ph ], [ %14, %.preheader39 ]
  %.13441 = phi ptr [ %59, %.lr.ph ], [ %12, %.preheader39 ]
  %51 = load i8, ptr %.13441, align 1, !tbaa !14
  %52 = getelementptr inbounds i8, ptr %.13441, i64 1
  %53 = load i8, ptr %52, align 1, !tbaa !14
  %54 = getelementptr inbounds i8, ptr %.13441, i64 2
  %55 = load i8, ptr %54, align 1, !tbaa !14
  %56 = tail call noundef float @_ZN3rmgL12getLuminanceEhhh(i8 noundef zeroext %51, i8 noundef zeroext %53, i8 noundef zeroext %55)
  %57 = fptoui float %56 to i8
  store i8 %57, ptr %.142, align 1, !tbaa !14
  %58 = getelementptr inbounds i8, ptr %.142, i64 1
  store i8 -1, ptr %58, align 1, !tbaa !14
  %59 = getelementptr inbounds i8, ptr %.13441, i64 3
  %60 = getelementptr inbounds i8, ptr %.142, i64 2
  %61 = add nuw nsw i64 %.03043, 1
  %exitcond.not = icmp eq i64 %61, %19
  br i1 %exitcond.not, label %.loopexit, label %.lr.ph, !llvm.loop !25

.lr.ph51:                                         ; preds = %.preheader, %.lr.ph51
  %.050 = phi i64 [ %76, %.lr.ph51 ], [ 0, %.preheader ]
  %.249 = phi ptr [ %75, %.lr.ph51 ], [ %14, %.preheader ]
  %.23548 = phi ptr [ %74, %.lr.ph51 ], [ %12, %.preheader ]
  %62 = load i8, ptr %.23548, align 1, !tbaa !14
  %63 = getelementptr inbounds i8, ptr %.23548, i64 1
  %64 = load i8, ptr %63, align 1, !tbaa !14
  %65 = getelementptr inbounds i8, ptr %.23548, i64 2
  %66 = load i8, ptr %65, align 1, !tbaa !14
  %67 = tail call noundef float @_ZN3rmgL12getLuminanceEhhh(i8 noundef zeroext %62, i8 noundef zeroext %64, i8 noundef zeroext %66)
  %68 = fptoui float %67 to i8
  store i8 %68, ptr %.249, align 1, !tbaa !14
  %69 = getelementptr inbounds i8, ptr %.23548, i64 3
  %70 = load i8, ptr %69, align 1, !tbaa !14
  %71 = getelementptr inbounds i8, ptr %.249, i64 1
  store i8 %70, ptr %71, align 1, !tbaa !14
  %72 = load i8, ptr %3, align 4, !tbaa !5
  %73 = zext i8 %72 to i64
  %74 = getelementptr inbounds i8, ptr %.23548, i64 %73
  %75 = getelementptr inbounds i8, ptr %.249, i64 2
  %76 = add nuw nsw i64 %.050, 1
  %exitcond57.not = icmp eq i64 %76, %19
  br i1 %exitcond57.not, label %.loopexit, label %.lr.ph51, !llvm.loop !26

.loopexit:                                        ; preds = %.lr.ph, %.lr.ph47.prol.loopexit, %.lr.ph47, %.lr.ph51, %middle.block, %.preheader39, %.preheader37, %.preheader, %6
  ret void
}

declare void @_ZN3rmg6BitmapC1Etth(ptr, i16, i16, i8) local_unnamed_addr

declare void @_ZN3rmg6BitmapC1ERKS0_(ptr, ptr) local_unnamed_addr

attributes #0 = { 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 #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, !8, i64 4}
!6 = !{!"_ZTSN3rmg6BitmapE", !7, i64 0, !7, i64 2, !8, i64 4, !10, i64 8}
!7 = !{!"short", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !7, i64 0}
!12 = !{!6, !7, i64 2}
!13 = !{!6, !10, i64 8}
!14 = !{!8, !8, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.unroll.disable"}
!17 = !{!18}
!18 = distinct !{!18, !19}
!19 = distinct !{!19, !"LVerDomain"}
!20 = distinct !{!20, !21, !22, !23}
!21 = !{!"llvm.loop.mustprogress"}
!22 = !{!"llvm.loop.isvectorized", i32 1}
!23 = !{!"llvm.loop.unroll.runtime.disable"}
!24 = distinct !{!24, !21, !22}
!25 = distinct !{!25, !21}
!26 = distinct !{!26, !21}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,ReassociatePass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass