; LLVM IR from ermig1979/Simd :: src/Simd/SimdBaseInterleave.ll (ZN4Simd4Base14InterleaveBgraEPKhmS2_mS2_mS2_mmmPhm)

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

29:                                               ; preds = %94, %12
  %30 = load i64, ptr %25, align 8, !tbaa !9
  %31 = load i64, ptr %22, align 8, !tbaa !9
  %32 = icmp ult i64 %30, %31
  br i1 %32, label %34, label %33

33:                                               ; preds = %29
  store i32 2, ptr %26, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %25) #2
  br label %97

34:                                               ; preds = %29
  call void @llvm.lifetime.start.p0(i64 8, ptr %27) #2
  store i64 0, ptr %27, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %28) #2
  store i64 0, ptr %28, align 8, !tbaa !9
  br label %35

35:                                               ; preds = %73, %34
  %36 = load i64, ptr %27, align 8, !tbaa !9
  %37 = load i64, ptr %21, align 8, !tbaa !9
  %38 = icmp ult i64 %36, %37
  br i1 %38, label %40, label %39

39:                                               ; preds = %35
  store i32 5, ptr %26, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %28) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %27) #2
  br label %78

40:                                               ; preds = %35
  %41 = load ptr, ptr %13, align 8, !tbaa !5
  %42 = load i64, ptr %27, align 8, !tbaa !9
  %43 = getelementptr inbounds i8, ptr %41, i64 %42
  %44 = load i8, ptr %43, align 1, !tbaa !11
  %45 = load ptr, ptr %23, align 8, !tbaa !5
  %46 = load i64, ptr %28, align 8, !tbaa !9
  %47 = add i64 %46, 0
  %48 = getelementptr inbounds i8, ptr %45, i64 %47
  store i8 %44, ptr %48, align 1, !tbaa !11
  %49 = load ptr, ptr %15, align 8, !tbaa !5
  %50 = load i64, ptr %27, align 8, !tbaa !9
  %51 = getelementptr inbounds i8, ptr %49, i64 %50
  %52 = load i8, ptr %51, align 1, !tbaa !11
  %53 = load ptr, ptr %23, align 8, !tbaa !5
  %54 = load i64, ptr %28, align 8, !tbaa !9
  %55 = add i64 %54, 1
  %56 = getelementptr inbounds i8, ptr %53, i64 %55
  store i8 %52, ptr %56, align 1, !tbaa !11
  %57 = load ptr, ptr %17, align 8, !tbaa !5
  %58 = load i64, ptr %27, align 8, !tbaa !9
  %59 = getelementptr inbounds i8, ptr %57, i64 %58
  %60 = load i8, ptr %59, align 1, !tbaa !11
  %61 = load ptr, ptr %23, align 8, !tbaa !5
  %62 = load i64, ptr %28, align 8, !tbaa !9
  %63 = add i64 %62, 2
  %64 = getelementptr inbounds i8, ptr %61, i64 %63
  store i8 %60, ptr %64, align 1, !tbaa !11
  %65 = load ptr, ptr %19, align 8, !tbaa !5
  %66 = load i64, ptr %27, align 8, !tbaa !9
  %67 = getelementptr inbounds i8, ptr %65, i64 %66
  %68 = load i8, ptr %67, align 1, !tbaa !11
  %69 = load ptr, ptr %23, align 8, !tbaa !5
  %70 = load i64, ptr %28, align 8, !tbaa !9
  %71 = add i64 %70, 3
  %72 = getelementptr inbounds i8, ptr %69, i64 %71
  store i8 %68, ptr %72, align 1, !tbaa !11
  br label %73

73:                                               ; preds = %40
  %74 = load i64, ptr %27, align 8, !tbaa !9
  %75 = add i64 %74, 1
  store i64 %75, ptr %27, align 8, !tbaa !9
  %76 = load i64, ptr %28, align 8, !tbaa !9
  %77 = add i64 %76, 4
  store i64 %77, ptr %28, align 8, !tbaa !9
  br label %35, !llvm.loop !12

78:                                               ; preds = %39
  %79 = load i64, ptr %14, align 8, !tbaa !9
  %80 = load ptr, ptr %13, align 8, !tbaa !5
  %81 = getelementptr inbounds i8, ptr %80, i64 %79
  store ptr %81, ptr %13, align 8, !tbaa !5
  %82 = load i64, ptr %16, align 8, !tbaa !9
  %83 = load ptr, ptr %15, align 8, !tbaa !5
  %84 = getelementptr inbounds i8, ptr %83, i64 %82
  store ptr %84, ptr %15, align 8, !tbaa !5
  %85 = load i64, ptr %18, align 8, !tbaa !9
  %86 = load ptr, ptr %17, align 8, !tbaa !5
  %87 = getelementptr inbounds i8, ptr %86, i64 %85
  store ptr %87, ptr %17, align 8, !tbaa !5
  %88 = load i64, ptr %20, align 8, !tbaa !9
  %89 = load ptr, ptr %19, align 8, !tbaa !5
  %90 = getelementptr inbounds i8, ptr %89, i64 %88
  store ptr %90, ptr %19, align 8, !tbaa !5
  %91 = load i64, ptr %24, align 8, !tbaa !9
  %92 = load ptr, ptr %23, align 8, !tbaa !5
  %93 = getelementptr inbounds i8, ptr %92, i64 %91
  store ptr %93, ptr %23, align 8, !tbaa !5
  br label %94

94:                                               ; preds = %78
  %95 = load i64, ptr %25, align 8, !tbaa !9
  %96 = add i64 %95, 1
  store i64 %96, ptr %25, align 8, !tbaa !9
  br label %29, !llvm.loop !14

97:                                               ; preds = %33
  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 @_ZN4Simd4Base14InterleaveBgraEPKhmS2_mS2_mS2_mmmPhm(ptr nocapture noundef readonly %0, i64 noundef %1, ptr nocapture noundef readonly %2, i64 noundef %3, ptr nocapture noundef readonly %4, i64 noundef %5, ptr nocapture noundef readonly %6, i64 noundef %7, i64 noundef %8, i64 noundef %9, ptr nocapture noundef writeonly %10, i64 noundef %11) local_unnamed_addr #0 {
  %.not = icmp eq i64 %9, 0
  %.not48 = icmp eq i64 %8, 0
  %or.cond = or i1 %.not, %.not48
  br i1 %or.cond, label %._crit_edge47, label %.preheader.us

.preheader.us:                                    ; preds = %12, %._crit_edge.us
  %.03346.us = phi i64 [ %36, %._crit_edge.us ], [ 0, %12 ]
  %.03445.us = phi ptr [ %31, %._crit_edge.us ], [ %0, %12 ]
  %.03544.us = phi ptr [ %35, %._crit_edge.us ], [ %10, %12 ]
  %.03643.us = phi ptr [ %32, %._crit_edge.us ], [ %2, %12 ]
  %.03742.us = phi ptr [ %33, %._crit_edge.us ], [ %4, %12 ]
  %.03841.us = phi ptr [ %34, %._crit_edge.us ], [ %6, %12 ]
  br label %13

13:                                               ; preds = %.preheader.us, %13
  %.040.us = phi i64 [ 0, %.preheader.us ], [ %30, %13 ]
  %.03239.us = phi i64 [ 0, %.preheader.us ], [ %29, %13 ]
  %14 = getelementptr inbounds i8, ptr %.03445.us, i64 %.03239.us
  %15 = load i8, ptr %14, align 1, !tbaa !5
  %16 = getelementptr inbounds i8, ptr %.03544.us, i64 %.040.us
  store i8 %15, ptr %16, align 1, !tbaa !5
  %17 = getelementptr inbounds i8, ptr %.03643.us, i64 %.03239.us
  %18 = load i8, ptr %17, align 1, !tbaa !5
  %19 = or disjoint i64 %.040.us, 1
  %20 = getelementptr inbounds i8, ptr %.03544.us, i64 %19
  store i8 %18, ptr %20, align 1, !tbaa !5
  %21 = getelementptr inbounds i8, ptr %.03742.us, i64 %.03239.us
  %22 = load i8, ptr %21, align 1, !tbaa !5
  %23 = or disjoint i64 %.040.us, 2
  %24 = getelementptr inbounds i8, ptr %.03544.us, i64 %23
  store i8 %22, ptr %24, align 1, !tbaa !5
  %25 = getelementptr inbounds i8, ptr %.03841.us, i64 %.03239.us
  %26 = load i8, ptr %25, align 1, !tbaa !5
  %27 = or disjoint i64 %.040.us, 3
  %28 = getelementptr inbounds i8, ptr %.03544.us, i64 %27
  store i8 %26, ptr %28, align 1, !tbaa !5
  %29 = add nuw i64 %.03239.us, 1
  %30 = add i64 %.040.us, 4
  %exitcond.not = icmp eq i64 %29, %8
  br i1 %exitcond.not, label %._crit_edge.us, label %13, !llvm.loop !8

._crit_edge.us:                                   ; preds = %13
  %31 = getelementptr inbounds i8, ptr %.03445.us, i64 %1
  %32 = getelementptr inbounds i8, ptr %.03643.us, i64 %3
  %33 = getelementptr inbounds i8, ptr %.03742.us, i64 %5
  %34 = getelementptr inbounds i8, ptr %.03841.us, i64 %7
  %35 = getelementptr inbounds i8, ptr %.03544.us, i64 %11
  %36 = add nuw i64 %.03346.us, 1
  %exitcond50.not = icmp eq i64 %36, %9
  br i1 %exitcond50.not, label %._crit_edge47, label %.preheader.us, !llvm.loop !10

._crit_edge47:                                    ; preds = %._crit_edge.us, %12
  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,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass