; LLVM IR from lfarcaro/ARINC653_ARMV7A_Z7000 :: ARINC653_ARMV7A_Z7000.sw/ARINC653_ARMV7A_Z7000_bsp/ps7_cortexa9_0/libsrc (MemCpy)

; 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: nounwind uwtable
define dso_local void @Xil_MemCpy(ptr noundef %0, ptr noundef %1, i32 noundef %2) #0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i32 %2, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #2
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %9, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #2
  %10 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %10, ptr %8, align 8, !tbaa !5
  br label %11

11:                                               ; preds = %15, %3
  %12 = load i32, ptr %6, align 4, !tbaa !9
  %13 = zext i32 %12 to i64
  %14 = icmp uge i64 %13, 4
  br i1 %14, label %15, label %27

15:                                               ; preds = %11
  %16 = load ptr, ptr %8, align 8, !tbaa !5
  %17 = load i32, ptr %16, align 4, !tbaa !9
  %18 = load ptr, ptr %7, align 8, !tbaa !5
  store i32 %17, ptr %18, align 4, !tbaa !9
  %19 = load ptr, ptr %7, align 8, !tbaa !5
  %20 = getelementptr inbounds i8, ptr %19, i64 4
  store ptr %20, ptr %7, align 8, !tbaa !5
  %21 = load ptr, ptr %8, align 8, !tbaa !5
  %22 = getelementptr inbounds i8, ptr %21, i64 4
  store ptr %22, ptr %8, align 8, !tbaa !5
  %23 = load i32, ptr %6, align 4, !tbaa !9
  %24 = zext i32 %23 to i64
  %25 = sub i64 %24, 4
  %26 = trunc i64 %25 to i32
  store i32 %26, ptr %6, align 4, !tbaa !9
  br label %11, !llvm.loop !11

27:                                               ; preds = %11
  br label %28

28:                                               ; preds = %31, %27
  %29 = load i32, ptr %6, align 4, !tbaa !9
  %30 = icmp ugt i32 %29, 0
  br i1 %30, label %31, label %41

31:                                               ; preds = %28
  %32 = load ptr, ptr %8, align 8, !tbaa !5
  %33 = load i8, ptr %32, align 1, !tbaa !13
  %34 = load ptr, ptr %7, align 8, !tbaa !5
  store i8 %33, ptr %34, align 1, !tbaa !13
  %35 = load ptr, ptr %7, align 8, !tbaa !5
  %36 = getelementptr inbounds i8, ptr %35, i64 1
  store ptr %36, ptr %7, align 8, !tbaa !5
  %37 = load ptr, ptr %8, align 8, !tbaa !5
  %38 = getelementptr inbounds i8, ptr %37, i64 1
  store ptr %38, ptr %8, align 8, !tbaa !5
  %39 = load i32, ptr %6, align 4, !tbaa !9
  %40 = sub i32 %39, 1
  store i32 %40, ptr %6, align 4, !tbaa !9
  br label %28, !llvm.loop !14

41:                                               ; preds = %28
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #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 = { 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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!7, !7, i64 0}
!14 = distinct !{!14, !12}


; 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: nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) uwtable
define dso_local void @Xil_MemCpy(ptr nocapture noundef writeonly %0, ptr nocapture noundef readonly %1, i32 noundef %2) local_unnamed_addr #0 {
  %4 = icmp ugt i32 %2, 3
  br i1 %4, label %.lr.ph.preheader, label %.preheader

.lr.ph.preheader:                                 ; preds = %3
  %5 = ptrtoint ptr %0 to i64
  %6 = ptrtoint ptr %1 to i64
  %7 = add i32 %2, -4
  %8 = lshr i32 %7, 2
  %narrow = add nuw nsw i32 %8, 1
  %9 = zext nneg i32 %narrow to i64
  %min.iters.check = icmp ult i32 %7, 28
  %10 = sub i64 %5, %6
  %diff.check = icmp ult i64 %10, 32
  %or.cond = or i1 %min.iters.check, %diff.check
  br i1 %or.cond, label %.lr.ph.preheader87, label %vector.ph

.lr.ph.preheader87:                               ; preds = %middle.block, %.lr.ph.preheader
  %.020.ph = phi ptr [ %1, %.lr.ph.preheader ], [ %ind.end, %middle.block ]
  %.01319.ph = phi ptr [ %0, %.lr.ph.preheader ], [ %ind.end34, %middle.block ]
  %.01518.ph = phi i32 [ %2, %.lr.ph.preheader ], [ %ind.end36, %middle.block ]
  br label %.lr.ph

vector.ph:                                        ; preds = %.lr.ph.preheader
  %n.vec = and i64 %9, 2147483640
  %11 = shl nuw nsw i64 %n.vec, 2
  %ind.end = getelementptr i8, ptr %1, i64 %11
  %12 = shl nuw nsw i64 %n.vec, 2
  %ind.end34 = getelementptr i8, ptr %0, i64 %12
  %.cast = trunc nuw nsw i64 %n.vec to i32
  %13 = shl i32 %.cast, 2
  %ind.end36 = sub i32 %2, %13
  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, 2
  %next.gep = getelementptr i8, ptr %1, i64 %offset.idx
  %offset.idx39 = shl i64 %index, 2
  %next.gep40 = getelementptr i8, ptr %0, i64 %offset.idx39
  %14 = getelementptr i8, ptr %next.gep, i64 16
  %wide.load = load <4 x i32>, ptr %next.gep, align 4, !tbaa !5
  %wide.load44 = load <4 x i32>, ptr %14, align 4, !tbaa !5
  %15 = getelementptr i8, ptr %next.gep40, i64 16
  store <4 x i32> %wide.load, ptr %next.gep40, align 4, !tbaa !5
  store <4 x i32> %wide.load44, ptr %15, align 4, !tbaa !5
  %index.next = add nuw i64 %index, 8
  %16 = icmp eq i64 %index.next, %n.vec
  br i1 %16, label %middle.block, label %vector.body, !llvm.loop !9

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %n.vec, %9
  br i1 %cmp.n, label %.preheader, label %.lr.ph.preheader87

.preheader:                                       ; preds = %.lr.ph, %middle.block, %3
  %.015.lcssa = phi i32 [ %2, %3 ], [ %ind.end36, %middle.block ], [ %32, %.lr.ph ]
  %.013.lcssa = phi ptr [ %0, %3 ], [ %ind.end34, %middle.block ], [ %30, %.lr.ph ]
  %.0.lcssa = phi ptr [ %1, %3 ], [ %ind.end, %middle.block ], [ %31, %.lr.ph ]
  %.not23 = icmp eq i32 %.015.lcssa, 0
  br i1 %.not23, label %._crit_edge, label %iter.check

iter.check:                                       ; preds = %.preheader
  %.0.lcssa47 = ptrtoint ptr %.0.lcssa to i64
  %.013.lcssa46 = ptrtoint ptr %.013.lcssa to i64
  %17 = zext i32 %.015.lcssa to i64
  %min.iters.check51 = icmp ult i32 %.015.lcssa, 8
  %18 = sub i64 %.013.lcssa46, %.0.lcssa47
  %diff.check48 = icmp ult i64 %18, 32
  %or.cond86 = select i1 %min.iters.check51, i1 true, i1 %diff.check48
  br i1 %or.cond86, label %.lr.ph27.preheader, label %vector.main.loop.iter.check

vector.main.loop.iter.check:                      ; preds = %iter.check
  %min.iters.check53 = icmp ult i32 %.015.lcssa, 32
  br i1 %min.iters.check53, label %vec.epilog.ph, label %vector.ph54

vector.ph54:                                      ; preds = %vector.main.loop.iter.check
  %n.vec56 = and i64 %17, 4294967264
  br label %vector.body57

vector.body57:                                    ; preds = %vector.body57, %vector.ph54
  %index58 = phi i64 [ 0, %vector.ph54 ], [ %index.next65, %vector.body57 ]
  %next.gep59 = getelementptr i8, ptr %.0.lcssa, i64 %index58
  %next.gep61 = getelementptr i8, ptr %.013.lcssa, i64 %index58
  %19 = getelementptr i8, ptr %next.gep59, i64 16
  %wide.load63 = load <16 x i8>, ptr %next.gep59, align 1, !tbaa !13
  %wide.load64 = load <16 x i8>, ptr %19, align 1, !tbaa !13
  %20 = getelementptr i8, ptr %next.gep61, i64 16
  store <16 x i8> %wide.load63, ptr %next.gep61, align 1, !tbaa !13
  store <16 x i8> %wide.load64, ptr %20, align 1, !tbaa !13
  %index.next65 = add nuw i64 %index58, 32
  %21 = icmp eq i64 %index.next65, %n.vec56
  br i1 %21, label %middle.block49, label %vector.body57, !llvm.loop !14

middle.block49:                                   ; preds = %vector.body57
  %cmp.n66 = icmp eq i64 %n.vec56, %17
  br i1 %cmp.n66, label %._crit_edge, label %vec.epilog.iter.check

vec.epilog.iter.check:                            ; preds = %middle.block49
  %.cast77 = trunc nuw i64 %n.vec56 to i32
  %ind.end78 = sub i32 %.015.lcssa, %.cast77
  %ind.end73 = getelementptr i8, ptr %.013.lcssa, i64 %n.vec56
  %ind.end70 = getelementptr i8, ptr %.0.lcssa, i64 %n.vec56
  %n.vec.remaining = and i64 %17, 24
  %min.epilog.iters.check = icmp eq i64 %n.vec.remaining, 0
  br i1 %min.epilog.iters.check, label %.lr.ph27.preheader, label %vec.epilog.ph

.lr.ph27.preheader:                               ; preds = %vec.epilog.middle.block, %iter.check, %vec.epilog.iter.check
  %.126.ph = phi ptr [ %.0.lcssa, %iter.check ], [ %ind.end70, %vec.epilog.iter.check ], [ %ind.end69, %vec.epilog.middle.block ]
  %.11425.ph = phi ptr [ %.013.lcssa, %iter.check ], [ %ind.end73, %vec.epilog.iter.check ], [ %ind.end72, %vec.epilog.middle.block ]
  %.11624.ph = phi i32 [ %.015.lcssa, %iter.check ], [ %ind.end78, %vec.epilog.iter.check ], [ %ind.end76, %vec.epilog.middle.block ]
  %22 = add i32 %.11624.ph, -1
  %xtraiter = and i32 %.11624.ph, 7
  %lcmp.mod.not = icmp eq i32 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.lr.ph27.prol.loopexit, label %.lr.ph27.prol

.lr.ph27.prol:                                    ; preds = %.lr.ph27.preheader, %.lr.ph27.prol
  %.126.prol = phi ptr [ %25, %.lr.ph27.prol ], [ %.126.ph, %.lr.ph27.preheader ]
  %.11425.prol = phi ptr [ %24, %.lr.ph27.prol ], [ %.11425.ph, %.lr.ph27.preheader ]
  %.11624.prol = phi i32 [ %26, %.lr.ph27.prol ], [ %.11624.ph, %.lr.ph27.preheader ]
  %prol.iter = phi i32 [ %prol.iter.next, %.lr.ph27.prol ], [ 0, %.lr.ph27.preheader ]
  %23 = load i8, ptr %.126.prol, align 1, !tbaa !13
  store i8 %23, ptr %.11425.prol, align 1, !tbaa !13
  %24 = getelementptr inbounds i8, ptr %.11425.prol, i64 1
  %25 = getelementptr inbounds i8, ptr %.126.prol, i64 1
  %26 = add i32 %.11624.prol, -1
  %prol.iter.next = add i32 %prol.iter, 1
  %prol.iter.cmp.not = icmp eq i32 %prol.iter.next, %xtraiter
  br i1 %prol.iter.cmp.not, label %.lr.ph27.prol.loopexit, label %.lr.ph27.prol, !llvm.loop !15

.lr.ph27.prol.loopexit:                           ; preds = %.lr.ph27.prol, %.lr.ph27.preheader
  %.126.unr = phi ptr [ %.126.ph, %.lr.ph27.preheader ], [ %25, %.lr.ph27.prol ]
  %.11425.unr = phi ptr [ %.11425.ph, %.lr.ph27.preheader ], [ %24, %.lr.ph27.prol ]
  %.11624.unr = phi i32 [ %.11624.ph, %.lr.ph27.preheader ], [ %26, %.lr.ph27.prol ]
  %27 = icmp ult i32 %22, 7
  br i1 %27, label %._crit_edge, label %.lr.ph27

vec.epilog.ph:                                    ; preds = %vector.main.loop.iter.check, %vec.epilog.iter.check
  %vec.epilog.resume.val = phi i64 [ %n.vec56, %vec.epilog.iter.check ], [ 0, %vector.main.loop.iter.check ]
  %n.vec68 = and i64 %17, 4294967288
  %ind.end69 = getelementptr i8, ptr %.0.lcssa, i64 %n.vec68
  %ind.end72 = getelementptr i8, ptr %.013.lcssa, i64 %n.vec68
  %.cast75 = trunc nuw i64 %n.vec68 to i32
  %ind.end76 = sub i32 %.015.lcssa, %.cast75
  br label %vec.epilog.vector.body

vec.epilog.vector.body:                           ; preds = %vec.epilog.vector.body, %vec.epilog.ph
  %index80 = phi i64 [ %vec.epilog.resume.val, %vec.epilog.ph ], [ %index.next84, %vec.epilog.vector.body ]
  %next.gep81 = getelementptr i8, ptr %.0.lcssa, i64 %index80
  %next.gep82 = getelementptr i8, ptr %.013.lcssa, i64 %index80
  %wide.load83 = load <8 x i8>, ptr %next.gep81, align 1, !tbaa !13
  store <8 x i8> %wide.load83, ptr %next.gep82, align 1, !tbaa !13
  %index.next84 = add nuw i64 %index80, 8
  %28 = icmp eq i64 %index.next84, %n.vec68
  br i1 %28, label %vec.epilog.middle.block, label %vec.epilog.vector.body, !llvm.loop !17

vec.epilog.middle.block:                          ; preds = %vec.epilog.vector.body
  %cmp.n85 = icmp eq i64 %n.vec68, %17
  br i1 %cmp.n85, label %._crit_edge, label %.lr.ph27.preheader

.lr.ph:                                           ; preds = %.lr.ph.preheader87, %.lr.ph
  %.020 = phi ptr [ %31, %.lr.ph ], [ %.020.ph, %.lr.ph.preheader87 ]
  %.01319 = phi ptr [ %30, %.lr.ph ], [ %.01319.ph, %.lr.ph.preheader87 ]
  %.01518 = phi i32 [ %32, %.lr.ph ], [ %.01518.ph, %.lr.ph.preheader87 ]
  %29 = load i32, ptr %.020, align 4, !tbaa !5
  store i32 %29, ptr %.01319, align 4, !tbaa !5
  %30 = getelementptr inbounds i8, ptr %.01319, i64 4
  %31 = getelementptr inbounds i8, ptr %.020, i64 4
  %32 = add i32 %.01518, -4
  %33 = icmp ugt i32 %32, 3
  br i1 %33, label %.lr.ph, label %.preheader, !llvm.loop !18

.lr.ph27:                                         ; preds = %.lr.ph27.prol.loopexit, %.lr.ph27
  %.126 = phi ptr [ %57, %.lr.ph27 ], [ %.126.unr, %.lr.ph27.prol.loopexit ]
  %.11425 = phi ptr [ %56, %.lr.ph27 ], [ %.11425.unr, %.lr.ph27.prol.loopexit ]
  %.11624 = phi i32 [ %58, %.lr.ph27 ], [ %.11624.unr, %.lr.ph27.prol.loopexit ]
  %34 = load i8, ptr %.126, align 1, !tbaa !13
  store i8 %34, ptr %.11425, align 1, !tbaa !13
  %35 = getelementptr inbounds i8, ptr %.11425, i64 1
  %36 = getelementptr inbounds i8, ptr %.126, i64 1
  %37 = load i8, ptr %36, align 1, !tbaa !13
  store i8 %37, ptr %35, align 1, !tbaa !13
  %38 = getelementptr inbounds i8, ptr %.11425, i64 2
  %39 = getelementptr inbounds i8, ptr %.126, i64 2
  %40 = load i8, ptr %39, align 1, !tbaa !13
  store i8 %40, ptr %38, align 1, !tbaa !13
  %41 = getelementptr inbounds i8, ptr %.11425, i64 3
  %42 = getelementptr inbounds i8, ptr %.126, i64 3
  %43 = load i8, ptr %42, align 1, !tbaa !13
  store i8 %43, ptr %41, align 1, !tbaa !13
  %44 = getelementptr inbounds i8, ptr %.11425, i64 4
  %45 = getelementptr inbounds i8, ptr %.126, i64 4
  %46 = load i8, ptr %45, align 1, !tbaa !13
  store i8 %46, ptr %44, align 1, !tbaa !13
  %47 = getelementptr inbounds i8, ptr %.11425, i64 5
  %48 = getelementptr inbounds i8, ptr %.126, i64 5
  %49 = load i8, ptr %48, align 1, !tbaa !13
  store i8 %49, ptr %47, align 1, !tbaa !13
  %50 = getelementptr inbounds i8, ptr %.11425, i64 6
  %51 = getelementptr inbounds i8, ptr %.126, i64 6
  %52 = load i8, ptr %51, align 1, !tbaa !13
  store i8 %52, ptr %50, align 1, !tbaa !13
  %53 = getelementptr inbounds i8, ptr %.11425, i64 7
  %54 = getelementptr inbounds i8, ptr %.126, i64 7
  %55 = load i8, ptr %54, align 1, !tbaa !13
  store i8 %55, ptr %53, align 1, !tbaa !13
  %56 = getelementptr inbounds i8, ptr %.11425, i64 8
  %57 = getelementptr inbounds i8, ptr %.126, i64 8
  %58 = add i32 %.11624, -8
  %.not.7 = icmp eq i32 %58, 0
  br i1 %.not.7, label %._crit_edge, label %.lr.ph27, !llvm.loop !19

._crit_edge:                                      ; preds = %.lr.ph27.prol.loopexit, %.lr.ph27, %middle.block49, %vec.epilog.middle.block, %.preheader
  ret void
}

attributes #0 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10, !11, !12}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!"llvm.loop.isvectorized", i32 1}
!12 = !{!"llvm.loop.unroll.runtime.disable"}
!13 = !{!7, !7, i64 0}
!14 = distinct !{!14, !10, !11, !12}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.unroll.disable"}
!17 = distinct !{!17, !10, !11, !12}
!18 = distinct !{!18, !10, !11}
!19 = distinct !{!19, !10, !11}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass