; LLVM IR from aap/librw :: src/pipeline.ll (ZN2rw11uninstColorEiPNS_4RGBAEPhjj)

; 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::RGBA" = type { i8, i8, i8, i8 }

@.str.2 = external hidden unnamed_addr constant [60 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [18 x i8], align 1
@__PRETTY_FUNCTION__._ZN2rw11uninstColorEiPNS_4RGBAEPhjj = external hidden unnamed_addr constant [59 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: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #1

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN2rw11uninstColorEiPNS_4RGBAEPhjj(i32 noundef %0, ptr noundef %1, ptr noundef %2, i32 noundef %3, i32 noundef %4) #2 {
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  store i32 %0, ptr %6, align 4, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !9
  store ptr %2, ptr %8, align 8, !tbaa !9
  store i32 %3, ptr %9, align 4, !tbaa !5
  store i32 %4, ptr %10, align 4, !tbaa !5
  %12 = load i32, ptr %6, align 4, !tbaa !5
  %13 = icmp eq i32 %12, 10
  br i1 %13, label %14, label %15

14:                                               ; preds = %5
  br label %17

15:                                               ; preds = %5
  call void @__assert_fail(ptr noundef @.str.7, ptr noundef @.str.2, i32 noundef 187, ptr noundef @__PRETTY_FUNCTION__._ZN2rw11uninstColorEiPNS_4RGBAEPhjj) #3
  unreachable

16:                                               ; No predecessors!
  br label %17

17:                                               ; preds = %16, %14
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  store i32 0, ptr %11, align 4, !tbaa !5
  br label %18

18:                                               ; preds = %50, %17
  %19 = load i32, ptr %11, align 4, !tbaa !5
  %20 = load i32, ptr %9, align 4, !tbaa !5
  %21 = icmp ult i32 %19, %20
  br i1 %21, label %23, label %22

22:                                               ; preds = %18
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  br label %53

23:                                               ; preds = %18
  %24 = load ptr, ptr %8, align 8, !tbaa !9
  %25 = getelementptr inbounds i8, ptr %24, i64 2
  %26 = load i8, ptr %25, align 1, !tbaa !11
  %27 = load ptr, ptr %7, align 8, !tbaa !9
  %28 = getelementptr inbounds %"struct.rw::RGBA", ptr %27, i32 0, i32 0
  store i8 %26, ptr %28, align 1, !tbaa !12
  %29 = load ptr, ptr %8, align 8, !tbaa !9
  %30 = getelementptr inbounds i8, ptr %29, i64 1
  %31 = load i8, ptr %30, align 1, !tbaa !11
  %32 = load ptr, ptr %7, align 8, !tbaa !9
  %33 = getelementptr inbounds %"struct.rw::RGBA", ptr %32, i32 0, i32 1
  store i8 %31, ptr %33, align 1, !tbaa !14
  %34 = load ptr, ptr %8, align 8, !tbaa !9
  %35 = getelementptr inbounds i8, ptr %34, i64 0
  %36 = load i8, ptr %35, align 1, !tbaa !11
  %37 = load ptr, ptr %7, align 8, !tbaa !9
  %38 = getelementptr inbounds %"struct.rw::RGBA", ptr %37, i32 0, i32 2
  store i8 %36, ptr %38, align 1, !tbaa !15
  %39 = load ptr, ptr %8, align 8, !tbaa !9
  %40 = getelementptr inbounds i8, ptr %39, i64 3
  %41 = load i8, ptr %40, align 1, !tbaa !11
  %42 = load ptr, ptr %7, align 8, !tbaa !9
  %43 = getelementptr inbounds %"struct.rw::RGBA", ptr %42, i32 0, i32 3
  store i8 %41, ptr %43, align 1, !tbaa !16
  %44 = load i32, ptr %10, align 4, !tbaa !5
  %45 = load ptr, ptr %8, align 8, !tbaa !9
  %46 = zext i32 %44 to i64
  %47 = getelementptr inbounds i8, ptr %45, i64 %46
  store ptr %47, ptr %8, align 8, !tbaa !9
  %48 = load ptr, ptr %7, align 8, !tbaa !9
  %49 = getelementptr inbounds %"struct.rw::RGBA", ptr %48, i32 1
  store ptr %49, ptr %7, align 8, !tbaa !9
  br label %50

50:                                               ; preds = %23
  %51 = load i32, ptr %11, align 4, !tbaa !5
  %52 = add i32 %51, 1
  store i32 %52, ptr %11, align 4, !tbaa !5
  br label %18, !llvm.loop !17

53:                                               ; preds = %22
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 }
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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = !{!13, !7, i64 0}
!13 = !{!"_ZTSN2rw4RGBAE", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3}
!14 = !{!13, !7, i64 1}
!15 = !{!13, !7, i64 2}
!16 = !{!13, !7, i64 3}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}


; 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 [60 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [18 x i8], align 1
@__PRETTY_FUNCTION__._ZN2rw11uninstColorEiPNS_4RGBAEPhjj = external hidden unnamed_addr constant [59 x i8], align 1

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN2rw11uninstColorEiPNS_4RGBAEPhjj(i32 noundef %0, ptr nocapture noundef writeonly %1, ptr nocapture noundef readonly %2, i32 noundef %3, i32 noundef %4) local_unnamed_addr #1 {
  %6 = icmp eq i32 %0, 10
  br i1 %6, label %.preheader, label %9

.preheader:                                       ; preds = %5
  %.not = icmp eq i32 %3, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader
  %7 = zext i32 %4 to i64
  %xtraiter = and i32 %3, 1
  %8 = icmp eq i32 %3, 1
  br i1 %8, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph.new

.lr.ph.new:                                       ; preds = %.lr.ph
  %unroll_iter = and i32 %3, -2
  br label %20

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

._crit_edge.loopexit.unr-lcssa:                   ; preds = %20, %.lr.ph
  %.01417.unr = phi ptr [ %1, %.lr.ph ], [ %44, %20 ]
  %.01516.unr = phi ptr [ %2, %.lr.ph ], [ %43, %20 ]
  %lcmp.mod.not = icmp eq i32 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge, label %._crit_edge.loopexit.epilog-lcssa

._crit_edge.loopexit.epilog-lcssa:                ; preds = %._crit_edge.loopexit.unr-lcssa
  %10 = getelementptr inbounds i8, ptr %.01516.unr, i64 2
  %11 = load i8, ptr %10, align 1, !tbaa !5
  store i8 %11, ptr %.01417.unr, align 1, !tbaa !8
  %12 = getelementptr inbounds i8, ptr %.01516.unr, i64 1
  %13 = load i8, ptr %12, align 1, !tbaa !5
  %14 = getelementptr inbounds i8, ptr %.01417.unr, i64 1
  store i8 %13, ptr %14, align 1, !tbaa !10
  %15 = load i8, ptr %.01516.unr, align 1, !tbaa !5
  %16 = getelementptr inbounds i8, ptr %.01417.unr, i64 2
  store i8 %15, ptr %16, align 1, !tbaa !11
  %17 = getelementptr inbounds i8, ptr %.01516.unr, i64 3
  %18 = load i8, ptr %17, align 1, !tbaa !5
  %19 = getelementptr inbounds i8, ptr %.01417.unr, i64 3
  store i8 %18, ptr %19, align 1, !tbaa !12
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit.epilog-lcssa, %._crit_edge.loopexit.unr-lcssa, %.preheader
  ret void

20:                                               ; preds = %20, %.lr.ph.new
  %.01417 = phi ptr [ %1, %.lr.ph.new ], [ %44, %20 ]
  %.01516 = phi ptr [ %2, %.lr.ph.new ], [ %43, %20 ]
  %niter = phi i32 [ 0, %.lr.ph.new ], [ %niter.next.1, %20 ]
  %21 = getelementptr inbounds i8, ptr %.01516, i64 2
  %22 = load i8, ptr %21, align 1, !tbaa !5
  store i8 %22, ptr %.01417, align 1, !tbaa !8
  %23 = getelementptr inbounds i8, ptr %.01516, i64 1
  %24 = load i8, ptr %23, align 1, !tbaa !5
  %25 = getelementptr inbounds i8, ptr %.01417, i64 1
  store i8 %24, ptr %25, align 1, !tbaa !10
  %26 = load i8, ptr %.01516, align 1, !tbaa !5
  %27 = getelementptr inbounds i8, ptr %.01417, i64 2
  store i8 %26, ptr %27, align 1, !tbaa !11
  %28 = getelementptr inbounds i8, ptr %.01516, i64 3
  %29 = load i8, ptr %28, align 1, !tbaa !5
  %30 = getelementptr inbounds i8, ptr %.01417, i64 3
  store i8 %29, ptr %30, align 1, !tbaa !12
  %31 = getelementptr inbounds i8, ptr %.01516, i64 %7
  %32 = getelementptr inbounds i8, ptr %.01417, i64 4
  %33 = getelementptr inbounds i8, ptr %31, i64 2
  %34 = load i8, ptr %33, align 1, !tbaa !5
  store i8 %34, ptr %32, align 1, !tbaa !8
  %35 = getelementptr inbounds i8, ptr %31, i64 1
  %36 = load i8, ptr %35, align 1, !tbaa !5
  %37 = getelementptr inbounds i8, ptr %.01417, i64 5
  store i8 %36, ptr %37, align 1, !tbaa !10
  %38 = load i8, ptr %31, align 1, !tbaa !5
  %39 = getelementptr inbounds i8, ptr %.01417, i64 6
  store i8 %38, ptr %39, align 1, !tbaa !11
  %40 = getelementptr inbounds i8, ptr %31, i64 3
  %41 = load i8, ptr %40, align 1, !tbaa !5
  %42 = getelementptr inbounds i8, ptr %.01417, i64 7
  store i8 %41, ptr %42, align 1, !tbaa !12
  %43 = getelementptr inbounds i8, ptr %31, i64 %7
  %44 = getelementptr inbounds i8, ptr %.01417, i64 8
  %niter.next.1 = add i32 %niter, 2
  %niter.ncmp.1 = icmp eq i32 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %._crit_edge.loopexit.unr-lcssa, label %20, !llvm.loop !13
}

attributes #0 = { 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 #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 = { 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, !6, i64 0}
!6 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !6, i64 0}
!9 = !{!"_ZTSN2rw4RGBAE", !6, i64 0, !6, i64 1, !6, i64 2, !6, i64 3}
!10 = !{!9, !6, i64 1}
!11 = !{!9, !6, i64 2}
!12 = !{!9, !6, i64 3}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


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