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

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @px_rgb_to_rgba(ptr noundef %0, ptr 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 ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #2
  %12 = load ptr, ptr %3, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.px_image_t, ptr %12, i32 0, i32 1
  %14 = load i32, ptr %13, align 8, !tbaa !9
  store i32 %14, ptr %5, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #2
  %15 = load ptr, ptr %3, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.px_image_t, ptr %15, i32 0, i32 2
  %17 = load i32, ptr %16, align 4, !tbaa !13
  store i32 %17, ptr %6, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #2
  %18 = load ptr, ptr %3, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.px_image_t, ptr %18, i32 0, i32 0
  %20 = load ptr, ptr %19, align 8, !tbaa !14
  store ptr %20, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #2
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.px_image_t, ptr %21, i32 0, i32 0
  %23 = load ptr, ptr %22, align 8, !tbaa !14
  store ptr %23, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #2
  store i32 0, ptr %9, align 4, !tbaa !12
  br label %24

24:                                               ; preds = %61, %2
  %25 = load i32, ptr %9, align 4, !tbaa !12
  %26 = load i32, ptr %6, align 4, !tbaa !12
  %27 = icmp slt i32 %25, %26
  br i1 %27, label %29, label %28

28:                                               ; preds = %24
  store i32 2, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #2
  br label %64

29:                                               ; preds = %24
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #2
  store i32 0, ptr %11, align 4, !tbaa !12
  br label %30

30:                                               ; preds = %57, %29
  %31 = load i32, ptr %11, align 4, !tbaa !12
  %32 = load i32, ptr %5, align 4, !tbaa !12
  %33 = icmp slt i32 %31, %32
  br i1 %33, label %35, label %34

34:                                               ; preds = %30
  store i32 5, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #2
  br label %60

35:                                               ; preds = %30
  %36 = load ptr, ptr %7, align 8, !tbaa !5
  %37 = getelementptr inbounds i8, ptr %36, i64 0
  %38 = load i8, ptr %37, align 1, !tbaa !15
  %39 = load ptr, ptr %8, align 8, !tbaa !5
  %40 = getelementptr inbounds i8, ptr %39, i64 0
  store i8 %38, ptr %40, align 1, !tbaa !15
  %41 = load ptr, ptr %7, align 8, !tbaa !5
  %42 = getelementptr inbounds i8, ptr %41, i64 1
  %43 = load i8, ptr %42, align 1, !tbaa !15
  %44 = load ptr, ptr %8, align 8, !tbaa !5
  %45 = getelementptr inbounds i8, ptr %44, i64 1
  store i8 %43, ptr %45, align 1, !tbaa !15
  %46 = load ptr, ptr %7, align 8, !tbaa !5
  %47 = getelementptr inbounds i8, ptr %46, i64 2
  %48 = load i8, ptr %47, align 1, !tbaa !15
  %49 = load ptr, ptr %8, align 8, !tbaa !5
  %50 = getelementptr inbounds i8, ptr %49, i64 2
  store i8 %48, ptr %50, align 1, !tbaa !15
  %51 = load ptr, ptr %8, align 8, !tbaa !5
  %52 = getelementptr inbounds i8, ptr %51, i64 3
  store i8 -1, ptr %52, align 1, !tbaa !15
  %53 = load ptr, ptr %8, align 8, !tbaa !5
  %54 = getelementptr inbounds i8, ptr %53, i64 4
  store ptr %54, ptr %8, align 8, !tbaa !5
  %55 = load ptr, ptr %7, align 8, !tbaa !5
  %56 = getelementptr inbounds i8, ptr %55, i64 3
  store ptr %56, ptr %7, align 8, !tbaa !5
  br label %57

57:                                               ; preds = %35
  %58 = load i32, ptr %11, align 4, !tbaa !12
  %59 = add nsw i32 %58, 1
  store i32 %59, ptr %11, align 4, !tbaa !12
  br label %30, !llvm.loop !16

60:                                               ; preds = %34
  br label %61

61:                                               ; preds = %60
  %62 = load i32, ptr %9, align 4, !tbaa !12
  %63 = add nsw i32 %62, 1
  store i32 %63, ptr %9, align 4, !tbaa !12
  br label %24, !llvm.loop !18

64:                                               ; preds = %28
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  ret void
}

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

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

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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, !11, i64 8}
!10 = !{!"_ZTS10px_image_t", !6, i64 0, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20}
!11 = !{!"int", !7, i64 0}
!12 = !{!11, !11, i64 0}
!13 = !{!10, !11, i64 12}
!14 = !{!10, !6, i64 0}
!15 = !{!7, !7, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = distinct !{!18, !17}


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

; Function Attrs: mustprogress nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) uwtable
define dso_local void @px_rgb_to_rgba(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 8
  %4 = load i32, ptr %3, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 12
  %6 = load i32, ptr %5, align 4, !tbaa !11
  %7 = icmp sgt i32 %6, 0
  %8 = icmp sgt i32 %4, 0
  %or.cond = select i1 %7, i1 %8, i1 false
  br i1 %or.cond, label %.preheader.us.preheader, label %._crit_edge29

.preheader.us.preheader:                          ; preds = %2
  %9 = load ptr, ptr %0, align 8, !tbaa !12
  %10 = load ptr, ptr %1, align 8, !tbaa !12
  %xtraiter = and i32 %4, 1
  %11 = icmp eq i32 %4, 1
  %unroll_iter = and i32 %4, 2147483646
  %lcmp.mod.not = icmp eq i32 %xtraiter, 0
  br label %.preheader.us

.preheader.us:                                    ; preds = %.preheader.us.preheader, %._crit_edge.us
  %.01828.us = phi i32 [ %42, %._crit_edge.us ], [ 0, %.preheader.us.preheader ]
  %.01927.us = phi ptr [ %.lcssa35, %._crit_edge.us ], [ %10, %.preheader.us.preheader ]
  %.02026.us = phi ptr [ %.lcssa, %._crit_edge.us ], [ %9, %.preheader.us.preheader ]
  br i1 %11, label %._crit_edge.us.unr-lcssa, label %.preheader.us.new

.preheader.us.new:                                ; preds = %.preheader.us, %.preheader.us.new
  %.123.us = phi ptr [ %30, %.preheader.us.new ], [ %.01927.us, %.preheader.us ]
  %.12122.us = phi ptr [ %31, %.preheader.us.new ], [ %.02026.us, %.preheader.us ]
  %niter = phi i32 [ %niter.next.1, %.preheader.us.new ], [ 0, %.preheader.us ]
  %12 = load i8, ptr %.12122.us, align 1, !tbaa !13
  store i8 %12, ptr %.123.us, align 1, !tbaa !13
  %13 = getelementptr inbounds i8, ptr %.12122.us, i64 1
  %14 = load i8, ptr %13, align 1, !tbaa !13
  %15 = getelementptr inbounds i8, ptr %.123.us, i64 1
  store i8 %14, ptr %15, align 1, !tbaa !13
  %16 = getelementptr inbounds i8, ptr %.12122.us, i64 2
  %17 = load i8, ptr %16, align 1, !tbaa !13
  %18 = getelementptr inbounds i8, ptr %.123.us, i64 2
  store i8 %17, ptr %18, align 1, !tbaa !13
  %19 = getelementptr inbounds i8, ptr %.123.us, i64 3
  store i8 -1, ptr %19, align 1, !tbaa !13
  %20 = getelementptr inbounds i8, ptr %.123.us, i64 4
  %21 = getelementptr inbounds i8, ptr %.12122.us, i64 3
  %22 = load i8, ptr %21, align 1, !tbaa !13
  store i8 %22, ptr %20, align 1, !tbaa !13
  %23 = getelementptr inbounds i8, ptr %.12122.us, i64 4
  %24 = load i8, ptr %23, align 1, !tbaa !13
  %25 = getelementptr inbounds i8, ptr %.123.us, i64 5
  store i8 %24, ptr %25, align 1, !tbaa !13
  %26 = getelementptr inbounds i8, ptr %.12122.us, i64 5
  %27 = load i8, ptr %26, align 1, !tbaa !13
  %28 = getelementptr inbounds i8, ptr %.123.us, i64 6
  store i8 %27, ptr %28, align 1, !tbaa !13
  %29 = getelementptr inbounds i8, ptr %.123.us, i64 7
  store i8 -1, ptr %29, align 1, !tbaa !13
  %30 = getelementptr inbounds i8, ptr %.123.us, i64 8
  %31 = getelementptr inbounds i8, ptr %.12122.us, i64 6
  %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.us.unr-lcssa, label %.preheader.us.new, !llvm.loop !14

._crit_edge.us.unr-lcssa:                         ; preds = %.preheader.us.new, %.preheader.us
  %.lcssa35.ph = phi ptr [ poison, %.preheader.us ], [ %30, %.preheader.us.new ]
  %.lcssa.ph = phi ptr [ poison, %.preheader.us ], [ %31, %.preheader.us.new ]
  %.123.us.unr = phi ptr [ %.01927.us, %.preheader.us ], [ %30, %.preheader.us.new ]
  %.12122.us.unr = phi ptr [ %.02026.us, %.preheader.us ], [ %31, %.preheader.us.new ]
  br i1 %lcmp.mod.not, label %._crit_edge.us, label %._crit_edge.us.epilog-lcssa

._crit_edge.us.epilog-lcssa:                      ; preds = %._crit_edge.us.unr-lcssa
  %32 = load i8, ptr %.12122.us.unr, align 1, !tbaa !13
  store i8 %32, ptr %.123.us.unr, align 1, !tbaa !13
  %33 = getelementptr inbounds i8, ptr %.12122.us.unr, i64 1
  %34 = load i8, ptr %33, align 1, !tbaa !13
  %35 = getelementptr inbounds i8, ptr %.123.us.unr, i64 1
  store i8 %34, ptr %35, align 1, !tbaa !13
  %36 = getelementptr inbounds i8, ptr %.12122.us.unr, i64 2
  %37 = load i8, ptr %36, align 1, !tbaa !13
  %38 = getelementptr inbounds i8, ptr %.123.us.unr, i64 2
  store i8 %37, ptr %38, align 1, !tbaa !13
  %39 = getelementptr inbounds i8, ptr %.123.us.unr, i64 3
  store i8 -1, ptr %39, align 1, !tbaa !13
  %40 = getelementptr inbounds i8, ptr %.123.us.unr, i64 4
  %41 = getelementptr inbounds i8, ptr %.12122.us.unr, i64 3
  br label %._crit_edge.us

._crit_edge.us:                                   ; preds = %._crit_edge.us.unr-lcssa, %._crit_edge.us.epilog-lcssa
  %.lcssa35 = phi ptr [ %.lcssa35.ph, %._crit_edge.us.unr-lcssa ], [ %40, %._crit_edge.us.epilog-lcssa ]
  %.lcssa = phi ptr [ %.lcssa.ph, %._crit_edge.us.unr-lcssa ], [ %41, %._crit_edge.us.epilog-lcssa ]
  %42 = add nuw nsw i32 %.01828.us, 1
  %exitcond32.not = icmp eq i32 %42, %6
  br i1 %exitcond32.not, label %._crit_edge29, label %.preheader.us, !llvm.loop !16

._crit_edge29:                                    ; preds = %._crit_edge.us, %2
  ret void
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) 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, !10, i64 8}
!6 = !{!"_ZTS10px_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++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!6, !10, i64 12}
!12 = !{!6, !7, i64 0}
!13 = !{!8, !8, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = distinct !{!16, !15}


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