; LLVM IR from ermig1979/Simd :: src/Simd/SimdBaseBgrToBgra.ll (ZN4Simd4Base14Bgr48pToBgra32EPKhmmmS2_mS2_mPhmh)

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

; 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
define dso_local void @_ZN4Simd4Base14Bgr48pToBgra32EPKhmmmS2_mS2_mPhmh(ptr noundef %0, i64 noundef %1, i64 noundef %2, i64 noundef %3, ptr noundef %4, i64 noundef %5, ptr noundef %6, i64 noundef %7, ptr noundef %8, i64 noundef %9, i8 noundef zeroext %10) #1 {
  %12 = alloca ptr, align 8
  %13 = alloca i64, align 8
  %14 = alloca i64, align 8
  %15 = alloca i64, align 8
  %16 = alloca ptr, align 8
  %17 = alloca i64, align 8
  %18 = alloca ptr, align 8
  %19 = alloca i64, align 8
  %20 = alloca ptr, align 8
  %21 = alloca i64, align 8
  %22 = alloca i8, align 1
  %23 = alloca i64, align 8
  %24 = alloca i32, align 4
  %25 = alloca ptr, align 8
  %26 = alloca ptr, align 8
  %27 = alloca ptr, align 8
  %28 = alloca ptr, align 8
  %29 = alloca i64, align 8
  store ptr %0, ptr %12, align 8, !tbaa !5
  store i64 %1, ptr %13, align 8, !tbaa !9
  store i64 %2, ptr %14, align 8, !tbaa !9
  store i64 %3, ptr %15, align 8, !tbaa !9
  store ptr %4, ptr %16, align 8, !tbaa !5
  store i64 %5, ptr %17, align 8, !tbaa !9
  store ptr %6, ptr %18, align 8, !tbaa !5
  store i64 %7, ptr %19, align 8, !tbaa !9
  store ptr %8, ptr %20, align 8, !tbaa !5
  store i64 %9, ptr %21, align 8, !tbaa !9
  store i8 %10, ptr %22, align 1, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %23) #2
  store i64 0, ptr %23, align 8, !tbaa !9
  br label %30

30:                                               ; preds = %88, %11
  %31 = load i64, ptr %23, align 8, !tbaa !9
  %32 = load i64, ptr %15, align 8, !tbaa !9
  %33 = icmp ult i64 %31, %32
  br i1 %33, label %35, label %34

34:                                               ; preds = %30
  store i32 2, ptr %24, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %23) #2
  br label %91

35:                                               ; preds = %30
  call void @llvm.lifetime.start.p0(i64 8, ptr %25) #2
  %36 = load ptr, ptr %12, align 8, !tbaa !5
  store ptr %36, ptr %25, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %26) #2
  %37 = load ptr, ptr %16, align 8, !tbaa !5
  store ptr %37, ptr %26, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %27) #2
  %38 = load ptr, ptr %18, align 8, !tbaa !5
  store ptr %38, ptr %27, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %28) #2
  %39 = load ptr, ptr %20, align 8, !tbaa !5
  store ptr %39, ptr %28, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %29) #2
  store i64 0, ptr %29, align 8, !tbaa !9
  br label %40

40:                                               ; preds = %72, %35
  %41 = load i64, ptr %29, align 8, !tbaa !9
  %42 = load i64, ptr %14, align 8, !tbaa !9
  %43 = icmp ult i64 %41, %42
  br i1 %43, label %45, label %44

44:                                               ; preds = %40
  store i32 5, ptr %24, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %29) #2
  br label %75

45:                                               ; preds = %40
  %46 = load ptr, ptr %25, align 8, !tbaa !5
  %47 = getelementptr inbounds i8, ptr %46, i64 0
  %48 = load i8, ptr %47, align 1, !tbaa !11
  %49 = load ptr, ptr %28, align 8, !tbaa !5
  %50 = getelementptr inbounds i8, ptr %49, i64 0
  store i8 %48, ptr %50, align 1, !tbaa !11
  %51 = load ptr, ptr %26, align 8, !tbaa !5
  %52 = getelementptr inbounds i8, ptr %51, i64 0
  %53 = load i8, ptr %52, align 1, !tbaa !11
  %54 = load ptr, ptr %28, align 8, !tbaa !5
  %55 = getelementptr inbounds i8, ptr %54, i64 1
  store i8 %53, ptr %55, align 1, !tbaa !11
  %56 = load ptr, ptr %27, align 8, !tbaa !5
  %57 = getelementptr inbounds i8, ptr %56, i64 0
  %58 = load i8, ptr %57, align 1, !tbaa !11
  %59 = load ptr, ptr %28, align 8, !tbaa !5
  %60 = getelementptr inbounds i8, ptr %59, i64 2
  store i8 %58, ptr %60, align 1, !tbaa !11
  %61 = load i8, ptr %22, align 1, !tbaa !11
  %62 = load ptr, ptr %28, align 8, !tbaa !5
  %63 = getelementptr inbounds i8, ptr %62, i64 3
  store i8 %61, ptr %63, align 1, !tbaa !11
  %64 = load ptr, ptr %25, align 8, !tbaa !5
  %65 = getelementptr inbounds i8, ptr %64, i64 2
  store ptr %65, ptr %25, align 8, !tbaa !5
  %66 = load ptr, ptr %26, align 8, !tbaa !5
  %67 = getelementptr inbounds i8, ptr %66, i64 2
  store ptr %67, ptr %26, align 8, !tbaa !5
  %68 = load ptr, ptr %27, align 8, !tbaa !5
  %69 = getelementptr inbounds i8, ptr %68, i64 2
  store ptr %69, ptr %27, align 8, !tbaa !5
  %70 = load ptr, ptr %28, align 8, !tbaa !5
  %71 = getelementptr inbounds i8, ptr %70, i64 4
  store ptr %71, ptr %28, align 8, !tbaa !5
  br label %72

72:                                               ; preds = %45
  %73 = load i64, ptr %29, align 8, !tbaa !9
  %74 = add i64 %73, 1
  store i64 %74, ptr %29, align 8, !tbaa !9
  br label %40, !llvm.loop !12

75:                                               ; preds = %44
  %76 = load i64, ptr %13, align 8, !tbaa !9
  %77 = load ptr, ptr %12, align 8, !tbaa !5
  %78 = getelementptr inbounds i8, ptr %77, i64 %76
  store ptr %78, ptr %12, align 8, !tbaa !5
  %79 = load i64, ptr %17, align 8, !tbaa !9
  %80 = load ptr, ptr %16, align 8, !tbaa !5
  %81 = getelementptr inbounds i8, ptr %80, i64 %79
  store ptr %81, ptr %16, align 8, !tbaa !5
  %82 = load i64, ptr %19, align 8, !tbaa !9
  %83 = load ptr, ptr %18, align 8, !tbaa !5
  %84 = getelementptr inbounds i8, ptr %83, i64 %82
  store ptr %84, ptr %18, align 8, !tbaa !5
  %85 = load i64, ptr %21, align 8, !tbaa !9
  %86 = load ptr, ptr %20, align 8, !tbaa !5
  %87 = getelementptr inbounds i8, ptr %86, i64 %85
  store ptr %87, ptr %20, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %28) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %27) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %26) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %25) #2
  br label %88

88:                                               ; preds = %75
  %89 = load i64, ptr %23, align 8, !tbaa !9
  %90 = add i64 %89, 1
  store i64 %90, ptr %23, align 8, !tbaa !9
  br label %30, !llvm.loop !14

91:                                               ; preds = %34
  ret void
}

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 = { 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 = !{!"long", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = distinct !{!14, !13}


; 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 @_ZN4Simd4Base14Bgr48pToBgra32EPKhmmmS2_mS2_mPhmh(ptr nocapture noundef readonly %0, i64 noundef %1, i64 noundef %2, i64 noundef %3, ptr nocapture noundef readonly %4, i64 noundef %5, ptr nocapture noundef readonly %6, i64 noundef %7, ptr nocapture noundef writeonly %8, i64 noundef %9, i8 noundef zeroext %10) local_unnamed_addr #0 {
  %.not = icmp eq i64 %3, 0
  %.not49 = icmp eq i64 %2, 0
  %or.cond = or i1 %.not, %.not49
  br i1 %or.cond, label %._crit_edge48, label %.preheader.us.preheader

.preheader.us.preheader:                          ; preds = %11
  %xtraiter = and i64 %2, 1
  %12 = icmp eq i64 %2, 1
  %unroll_iter = and i64 %2, -2
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br label %.preheader.us

.preheader.us:                                    ; preds = %.preheader.us.preheader, %._crit_edge.us
  %.03347.us = phi i64 [ %43, %._crit_edge.us ], [ 0, %.preheader.us.preheader ]
  %.03446.us = phi ptr [ %39, %._crit_edge.us ], [ %0, %.preheader.us.preheader ]
  %.03545.us = phi ptr [ %40, %._crit_edge.us ], [ %4, %.preheader.us.preheader ]
  %.03644.us = phi ptr [ %42, %._crit_edge.us ], [ %8, %.preheader.us.preheader ]
  %.03743.us = phi ptr [ %41, %._crit_edge.us ], [ %6, %.preheader.us.preheader ]
  br i1 %12, label %._crit_edge.us.unr-lcssa, label %.preheader.us.new

.preheader.us.new:                                ; preds = %.preheader.us, %.preheader.us.new
  %.02941.us = phi ptr [ %32, %.preheader.us.new ], [ %.03644.us, %.preheader.us ]
  %.03040.us = phi ptr [ %31, %.preheader.us.new ], [ %.03743.us, %.preheader.us ]
  %.03139.us = phi ptr [ %30, %.preheader.us.new ], [ %.03545.us, %.preheader.us ]
  %.03238.us = phi ptr [ %29, %.preheader.us.new ], [ %.03446.us, %.preheader.us ]
  %niter = phi i64 [ %niter.next.1, %.preheader.us.new ], [ 0, %.preheader.us ]
  %13 = load i8, ptr %.03238.us, align 1, !tbaa !5
  store i8 %13, ptr %.02941.us, align 1, !tbaa !5
  %14 = load i8, ptr %.03139.us, align 1, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %.02941.us, i64 1
  store i8 %14, ptr %15, align 1, !tbaa !5
  %16 = load i8, ptr %.03040.us, align 1, !tbaa !5
  %17 = getelementptr inbounds i8, ptr %.02941.us, i64 2
  store i8 %16, ptr %17, align 1, !tbaa !5
  %18 = getelementptr inbounds i8, ptr %.02941.us, i64 3
  store i8 %10, ptr %18, align 1, !tbaa !5
  %19 = getelementptr inbounds i8, ptr %.03238.us, i64 2
  %20 = getelementptr inbounds i8, ptr %.03139.us, i64 2
  %21 = getelementptr inbounds i8, ptr %.03040.us, i64 2
  %22 = getelementptr inbounds i8, ptr %.02941.us, i64 4
  %23 = load i8, ptr %19, align 1, !tbaa !5
  store i8 %23, ptr %22, align 1, !tbaa !5
  %24 = load i8, ptr %20, align 1, !tbaa !5
  %25 = getelementptr inbounds i8, ptr %.02941.us, i64 5
  store i8 %24, ptr %25, align 1, !tbaa !5
  %26 = load i8, ptr %21, align 1, !tbaa !5
  %27 = getelementptr inbounds i8, ptr %.02941.us, i64 6
  store i8 %26, ptr %27, align 1, !tbaa !5
  %28 = getelementptr inbounds i8, ptr %.02941.us, i64 7
  store i8 %10, ptr %28, align 1, !tbaa !5
  %29 = getelementptr inbounds i8, ptr %.03238.us, i64 4
  %30 = getelementptr inbounds i8, ptr %.03139.us, i64 4
  %31 = getelementptr inbounds i8, ptr %.03040.us, i64 4
  %32 = getelementptr inbounds i8, ptr %.02941.us, i64 8
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %._crit_edge.us.unr-lcssa, label %.preheader.us.new, !llvm.loop !8

._crit_edge.us.unr-lcssa:                         ; preds = %.preheader.us.new, %.preheader.us
  %.02941.us.unr = phi ptr [ %.03644.us, %.preheader.us ], [ %32, %.preheader.us.new ]
  %.03040.us.unr = phi ptr [ %.03743.us, %.preheader.us ], [ %31, %.preheader.us.new ]
  %.03139.us.unr = phi ptr [ %.03545.us, %.preheader.us ], [ %30, %.preheader.us.new ]
  %.03238.us.unr = phi ptr [ %.03446.us, %.preheader.us ], [ %29, %.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
  %33 = load i8, ptr %.03238.us.unr, align 1, !tbaa !5
  store i8 %33, ptr %.02941.us.unr, align 1, !tbaa !5
  %34 = load i8, ptr %.03139.us.unr, align 1, !tbaa !5
  %35 = getelementptr inbounds i8, ptr %.02941.us.unr, i64 1
  store i8 %34, ptr %35, align 1, !tbaa !5
  %36 = load i8, ptr %.03040.us.unr, align 1, !tbaa !5
  %37 = getelementptr inbounds i8, ptr %.02941.us.unr, i64 2
  store i8 %36, ptr %37, align 1, !tbaa !5
  %38 = getelementptr inbounds i8, ptr %.02941.us.unr, i64 3
  store i8 %10, ptr %38, align 1, !tbaa !5
  br label %._crit_edge.us

._crit_edge.us:                                   ; preds = %._crit_edge.us.unr-lcssa, %._crit_edge.us.epilog-lcssa
  %39 = getelementptr inbounds i8, ptr %.03446.us, i64 %1
  %40 = getelementptr inbounds i8, ptr %.03545.us, i64 %5
  %41 = getelementptr inbounds i8, ptr %.03743.us, i64 %7
  %42 = getelementptr inbounds i8, ptr %.03644.us, i64 %9
  %43 = add nuw i64 %.03347.us, 1
  %exitcond51.not = icmp eq i64 %43, %3
  br i1 %exitcond51.not, label %._crit_edge48, label %.preheader.us, !llvm.loop !10

._crit_edge48:                                    ; preds = %._crit_edge.us, %11
  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, !6, i64 0}
!6 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = distinct !{!8, !9}
!9 = !{!"llvm.loop.mustprogress"}
!10 = distinct !{!10, !9}


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