; LLVM IR from gaoshanlee193/riscv-vector4wireless-extension :: toolchain/benchmark/env/v (string)

; 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 ptr @memcpy(ptr noundef %0, ptr noundef %1, i64 noundef %2) #0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i64 %2, ptr %6, align 8, !tbaa !9
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = ptrtoint ptr %11 to i64
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  %14 = ptrtoint ptr %13 to i64
  %15 = or i64 %12, %14
  %16 = load i64, ptr %6, align 8, !tbaa !9
  %17 = or i64 %15, %16
  %18 = and i64 %17, 7
  %19 = icmp eq i64 %18, 0
  br i1 %19, label %20, label %36

20:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #2
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %21, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #2
  %22 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %22, ptr %8, align 8, !tbaa !5
  br label %23

23:                                               ; preds = %29, %20
  %24 = load ptr, ptr %8, align 8, !tbaa !5
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = load i64, ptr %6, align 8, !tbaa !9
  %27 = getelementptr inbounds i8, ptr %25, i64 %26
  %28 = icmp ult ptr %24, %27
  br i1 %28, label %29, label %35

29:                                               ; preds = %23
  %30 = load ptr, ptr %7, align 8, !tbaa !5
  %31 = getelementptr inbounds i64, ptr %30, i32 1
  store ptr %31, ptr %7, align 8, !tbaa !5
  %32 = load i64, ptr %30, align 8, !tbaa !9
  %33 = load ptr, ptr %8, align 8, !tbaa !5
  %34 = getelementptr inbounds i64, ptr %33, i32 1
  store ptr %34, ptr %8, align 8, !tbaa !5
  store i64 %32, ptr %33, align 8, !tbaa !9
  br label %23, !llvm.loop !11

35:                                               ; preds = %23
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #2
  br label %52

36:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #2
  %37 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %37, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #2
  %38 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %38, ptr %10, align 8, !tbaa !5
  br label %39

39:                                               ; preds = %45, %36
  %40 = load ptr, ptr %10, align 8, !tbaa !5
  %41 = load ptr, ptr %4, align 8, !tbaa !5
  %42 = load i64, ptr %6, align 8, !tbaa !9
  %43 = getelementptr inbounds i8, ptr %41, i64 %42
  %44 = icmp ult ptr %40, %43
  br i1 %44, label %45, label %51

45:                                               ; preds = %39
  %46 = load ptr, ptr %9, align 8, !tbaa !5
  %47 = getelementptr inbounds i8, ptr %46, i32 1
  store ptr %47, ptr %9, align 8, !tbaa !5
  %48 = load i8, ptr %46, align 1, !tbaa !13
  %49 = load ptr, ptr %10, align 8, !tbaa !5
  %50 = getelementptr inbounds i8, ptr %49, i32 1
  store ptr %50, ptr %10, align 8, !tbaa !5
  store i8 %48, ptr %49, align 1, !tbaa !13
  br label %39, !llvm.loop !14

51:                                               ; preds = %39
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #2
  br label %52

52:                                               ; preds = %51, %35
  %53 = load ptr, ptr %4, align 8, !tbaa !5
  ret ptr %53
}

; 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 = !{!"long", !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 noundef ptr @memcpy(ptr noundef returned %0, ptr noundef %1, i64 noundef %2) local_unnamed_addr #0 {
  %4 = ptrtoint ptr %0 to i64
  %5 = ptrtoint ptr %1 to i64
  %6 = ptrtoint ptr %0 to i64
  %7 = ptrtoint ptr %1 to i64
  %8 = ptrtoint ptr %0 to i64
  %9 = ptrtoint ptr %1 to i64
  %10 = or i64 %9, %8
  %11 = or i64 %10, %2
  %12 = and i64 %11, 7
  %13 = icmp eq i64 %12, 0
  %14 = getelementptr inbounds i8, ptr %0, i64 %2
  %15 = icmp sgt i64 %2, 0
  br i1 %13, label %.preheader, label %.preheader20

.preheader20:                                     ; preds = %3
  br i1 %15, label %iter.check, label %.loopexit

iter.check:                                       ; preds = %.preheader20
  %16 = add i64 %6, %2
  %17 = add i64 %6, 1
  %umax = tail call i64 @llvm.umax.i64(i64 %16, i64 %17)
  %18 = sub i64 %umax, %6
  %min.iters.check = icmp ult i64 %18, 8
  %19 = sub i64 %8, %7
  %diff.check = icmp ult i64 %19, 32
  %or.cond = or i1 %min.iters.check, %diff.check
  br i1 %or.cond, label %.lr.ph.preheader, label %vector.main.loop.iter.check

vector.main.loop.iter.check:                      ; preds = %iter.check
  %min.iters.check30 = icmp ult i64 %18, 32
  br i1 %min.iters.check30, label %vec.epilog.ph, label %vector.ph

vector.ph:                                        ; preds = %vector.main.loop.iter.check
  %n.vec = and i64 %18, -32
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %next.gep = getelementptr i8, ptr %0, i64 %index
  %next.gep32 = getelementptr i8, ptr %1, i64 %index
  %20 = getelementptr i8, ptr %next.gep32, i64 16
  %wide.load = load <16 x i8>, ptr %next.gep32, align 1, !tbaa !5
  %wide.load34 = load <16 x i8>, ptr %20, align 1, !tbaa !5
  %21 = getelementptr i8, ptr %next.gep, i64 16
  store <16 x i8> %wide.load, ptr %next.gep, align 1, !tbaa !5
  store <16 x i8> %wide.load34, ptr %21, align 1, !tbaa !5
  %index.next = add nuw i64 %index, 32
  %22 = icmp eq i64 %index.next, %n.vec
  br i1 %22, label %middle.block, label %vector.body, !llvm.loop !8

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %18, %n.vec
  br i1 %cmp.n, label %.loopexit, label %vec.epilog.iter.check

vec.epilog.iter.check:                            ; preds = %middle.block
  %ind.end39 = getelementptr i8, ptr %1, i64 %n.vec
  %ind.end37 = getelementptr i8, ptr %0, i64 %n.vec
  %n.vec.remaining = and i64 %18, 24
  %min.epilog.iters.check = icmp eq i64 %n.vec.remaining, 0
  br i1 %min.epilog.iters.check, label %.lr.ph.preheader, label %vec.epilog.ph

.lr.ph.preheader:                                 ; preds = %vec.epilog.middle.block, %iter.check, %vec.epilog.iter.check
  %.023.ph = phi ptr [ %0, %iter.check ], [ %ind.end37, %vec.epilog.iter.check ], [ %ind.end, %vec.epilog.middle.block ]
  %.01722.ph = phi ptr [ %1, %iter.check ], [ %ind.end39, %vec.epilog.iter.check ], [ %ind.end38, %vec.epilog.middle.block ]
  br label %.lr.ph

vec.epilog.ph:                                    ; preds = %vector.main.loop.iter.check, %vec.epilog.iter.check
  %vec.epilog.resume.val = phi i64 [ %n.vec, %vec.epilog.iter.check ], [ 0, %vector.main.loop.iter.check ]
  %n.vec36 = and i64 %18, -8
  %ind.end = getelementptr i8, ptr %0, i64 %n.vec36
  %ind.end38 = getelementptr i8, ptr %1, i64 %n.vec36
  br label %vec.epilog.vector.body

vec.epilog.vector.body:                           ; preds = %vec.epilog.vector.body, %vec.epilog.ph
  %index41 = phi i64 [ %vec.epilog.resume.val, %vec.epilog.ph ], [ %index.next45, %vec.epilog.vector.body ]
  %next.gep42 = getelementptr i8, ptr %0, i64 %index41
  %next.gep43 = getelementptr i8, ptr %1, i64 %index41
  %wide.load44 = load <8 x i8>, ptr %next.gep43, align 1, !tbaa !5
  store <8 x i8> %wide.load44, ptr %next.gep42, align 1, !tbaa !5
  %index.next45 = add nuw i64 %index41, 8
  %23 = icmp eq i64 %index.next45, %n.vec36
  br i1 %23, label %vec.epilog.middle.block, label %vec.epilog.vector.body, !llvm.loop !12

vec.epilog.middle.block:                          ; preds = %vec.epilog.vector.body
  %cmp.n46 = icmp eq i64 %18, %n.vec36
  br i1 %cmp.n46, label %.loopexit, label %.lr.ph.preheader

.preheader:                                       ; preds = %3
  br i1 %15, label %.lr.ph26.preheader, label %.loopexit

.lr.ph26.preheader:                               ; preds = %.preheader
  %24 = add i64 %4, %2
  %25 = add i64 %4, 8
  %umax49 = tail call i64 @llvm.umax.i64(i64 %24, i64 %25)
  %26 = xor i64 %4, -1
  %27 = add i64 %umax49, %26
  %28 = lshr i64 %27, 3
  %29 = add nuw nsw i64 %28, 1
  %min.iters.check51 = icmp ult i64 %27, 56
  %30 = sub i64 %6, %5
  %diff.check48 = icmp ult i64 %30, 32
  %or.cond70 = or i1 %min.iters.check51, %diff.check48
  br i1 %or.cond70, label %.lr.ph26.preheader71, label %vector.ph52

vector.ph52:                                      ; preds = %.lr.ph26.preheader
  %n.vec54 = and i64 %29, 4611686018427387900
  %31 = shl i64 %n.vec54, 3
  %ind.end55 = getelementptr i8, ptr %0, i64 %31
  %32 = shl i64 %n.vec54, 3
  %ind.end57 = getelementptr i8, ptr %1, i64 %32
  br label %vector.body59

vector.body59:                                    ; preds = %vector.body59, %vector.ph52
  %index60 = phi i64 [ 0, %vector.ph52 ], [ %index.next68, %vector.body59 ]
  %offset.idx = shl i64 %index60, 3
  %next.gep61 = getelementptr i8, ptr %0, i64 %offset.idx
  %offset.idx63 = shl i64 %index60, 3
  %next.gep64 = getelementptr i8, ptr %1, i64 %offset.idx63
  %33 = getelementptr i8, ptr %next.gep64, i64 16
  %wide.load66 = load <2 x i64>, ptr %next.gep64, align 8, !tbaa !13
  %wide.load67 = load <2 x i64>, ptr %33, align 8, !tbaa !13
  %34 = getelementptr i8, ptr %next.gep61, i64 16
  store <2 x i64> %wide.load66, ptr %next.gep61, align 8, !tbaa !13
  store <2 x i64> %wide.load67, ptr %34, align 8, !tbaa !13
  %index.next68 = add nuw i64 %index60, 4
  %35 = icmp eq i64 %index.next68, %n.vec54
  br i1 %35, label %middle.block50, label %vector.body59, !llvm.loop !15

middle.block50:                                   ; preds = %vector.body59
  %cmp.n69 = icmp eq i64 %29, %n.vec54
  br i1 %cmp.n69, label %.loopexit, label %.lr.ph26.preheader71

.lr.ph26.preheader71:                             ; preds = %middle.block50, %.lr.ph26.preheader
  %.01825.ph = phi ptr [ %0, %.lr.ph26.preheader ], [ %ind.end55, %middle.block50 ]
  %.01924.ph = phi ptr [ %1, %.lr.ph26.preheader ], [ %ind.end57, %middle.block50 ]
  br label %.lr.ph26

.lr.ph26:                                         ; preds = %.lr.ph26.preheader71, %.lr.ph26
  %.01825 = phi ptr [ %38, %.lr.ph26 ], [ %.01825.ph, %.lr.ph26.preheader71 ]
  %.01924 = phi ptr [ %36, %.lr.ph26 ], [ %.01924.ph, %.lr.ph26.preheader71 ]
  %36 = getelementptr inbounds i8, ptr %.01924, i64 8
  %37 = load i64, ptr %.01924, align 8, !tbaa !13
  %38 = getelementptr inbounds i8, ptr %.01825, i64 8
  store i64 %37, ptr %.01825, align 8, !tbaa !13
  %39 = icmp ult ptr %38, %14
  br i1 %39, label %.lr.ph26, label %.loopexit, !llvm.loop !16

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %.023 = phi ptr [ %42, %.lr.ph ], [ %.023.ph, %.lr.ph.preheader ]
  %.01722 = phi ptr [ %40, %.lr.ph ], [ %.01722.ph, %.lr.ph.preheader ]
  %40 = getelementptr inbounds i8, ptr %.01722, i64 1
  %41 = load i8, ptr %.01722, align 1, !tbaa !5
  %42 = getelementptr inbounds i8, ptr %.023, i64 1
  store i8 %41, ptr %.023, align 1, !tbaa !5
  %43 = icmp ult ptr %42, %14
  br i1 %43, label %.lr.ph, label %.loopexit, !llvm.loop !17

.loopexit:                                        ; preds = %.lr.ph, %.lr.ph26, %middle.block, %vec.epilog.middle.block, %middle.block50, %.preheader20, %.preheader
  ret ptr %0
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.umax.i64(i64, i64) #1

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" }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }

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


; Effective O3 passes: GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass