; 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: 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: nounwind uwtable
define dso_local ptr @memset(ptr noundef %0, i32 noundef %1, i64 noundef %2) #1 {
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  store i64 %2, ptr %6, align 8, !tbaa !11
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  %11 = ptrtoint ptr %10 to i64
  %12 = load i64, ptr %6, align 8, !tbaa !11
  %13 = or i64 %11, %12
  %14 = and i64 %13, 7
  %15 = icmp eq i64 %14, 0
  br i1 %15, label %16, label %45

16:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #2
  %17 = load i32, ptr %5, align 4, !tbaa !9
  %18 = and i32 %17, 255
  %19 = sext i32 %18 to i64
  store i64 %19, ptr %7, align 8, !tbaa !11
  %20 = load i64, ptr %7, align 8, !tbaa !11
  %21 = shl i64 %20, 8
  %22 = load i64, ptr %7, align 8, !tbaa !11
  %23 = or i64 %22, %21
  store i64 %23, ptr %7, align 8, !tbaa !11
  %24 = load i64, ptr %7, align 8, !tbaa !11
  %25 = shl i64 %24, 16
  %26 = load i64, ptr %7, align 8, !tbaa !11
  %27 = or i64 %26, %25
  store i64 %27, ptr %7, align 8, !tbaa !11
  %28 = load i64, ptr %7, align 8, !tbaa !11
  %29 = shl i64 %28, 16
  %30 = shl i64 %29, 16
  %31 = load i64, ptr %7, align 8, !tbaa !11
  %32 = or i64 %31, %30
  store i64 %32, ptr %7, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #2
  %33 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %33, ptr %8, align 8, !tbaa !5
  br label %34

34:                                               ; preds = %40, %16
  %35 = load ptr, ptr %8, align 8, !tbaa !5
  %36 = load ptr, ptr %4, align 8, !tbaa !5
  %37 = load i64, ptr %6, align 8, !tbaa !11
  %38 = getelementptr inbounds i8, ptr %36, i64 %37
  %39 = icmp ult ptr %35, %38
  br i1 %39, label %40, label %44

40:                                               ; preds = %34
  %41 = load i64, ptr %7, align 8, !tbaa !11
  %42 = load ptr, ptr %8, align 8, !tbaa !5
  %43 = getelementptr inbounds i64, ptr %42, i32 1
  store ptr %43, ptr %8, align 8, !tbaa !5
  store i64 %41, ptr %42, align 8, !tbaa !11
  br label %34, !llvm.loop !13

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

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

47:                                               ; preds = %53, %45
  %48 = load ptr, ptr %9, align 8, !tbaa !5
  %49 = load ptr, ptr %4, align 8, !tbaa !5
  %50 = load i64, ptr %6, align 8, !tbaa !11
  %51 = getelementptr inbounds i8, ptr %49, i64 %50
  %52 = icmp ult ptr %48, %51
  br i1 %52, label %53, label %58

53:                                               ; preds = %47
  %54 = load i32, ptr %5, align 4, !tbaa !9
  %55 = trunc i32 %54 to i8
  %56 = load ptr, ptr %9, align 8, !tbaa !5
  %57 = getelementptr inbounds i8, ptr %56, i32 1
  store ptr %57, ptr %9, align 8, !tbaa !5
  store i8 %55, ptr %56, align 1, !tbaa !15
  br label %47, !llvm.loop !16

58:                                               ; preds = %47
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #2
  br label %59

59:                                               ; preds = %58, %44
  %60 = load ptr, ptr %4, align 8, !tbaa !5
  ret ptr %60
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{!7, !7, i64 0}
!16 = distinct !{!16, !14}


; 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(write, inaccessiblemem: none) uwtable
define dso_local noundef ptr @memset(ptr noundef returned %0, i32 noundef %1, i64 noundef %2) local_unnamed_addr #0 {
  %4 = ptrtoint ptr %0 to i64
  %5 = or i64 %4, %2
  %6 = and i64 %5, 7
  %7 = icmp eq i64 %6, 0
  br i1 %7, label %17, label %.preheader

.preheader:                                       ; preds = %3
  %8 = getelementptr inbounds i8, ptr %0, i64 %2
  %9 = icmp sgt i64 %2, 0
  br i1 %9, label %iter.check, label %.loopexit

iter.check:                                       ; preds = %.preheader
  %10 = trunc i32 %1 to i8
  %11 = add i64 %4, %2
  %12 = add i64 %4, 1
  %umax = tail call i64 @llvm.umax.i64(i64 %11, i64 %12)
  %13 = sub i64 %umax, %4
  %min.iters.check = icmp ult i64 %13, 8
  br i1 %min.iters.check, label %vec.epilog.scalar.ph.preheader, label %vector.main.loop.iter.check

vector.main.loop.iter.check:                      ; preds = %iter.check
  %min.iters.check30 = icmp ult i64 %13, 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 %13, -32
  %broadcast.splatinsert = insertelement <16 x i8> poison, i8 %10, i64 0
  %broadcast.splat = shufflevector <16 x i8> %broadcast.splatinsert, <16 x i8> poison, <16 x i32> zeroinitializer
  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
  %14 = getelementptr i8, ptr %next.gep, i64 16
  store <16 x i8> %broadcast.splat, ptr %next.gep, align 1, !tbaa !5
  store <16 x i8> %broadcast.splat, ptr %14, align 1, !tbaa !5
  %index.next = add nuw i64 %index, 32
  %15 = icmp eq i64 %index.next, %n.vec
  br i1 %15, label %middle.block, label %vector.body, !llvm.loop !8

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

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

vec.epilog.scalar.ph.preheader:                   ; preds = %vec.epilog.middle.block, %iter.check, %vec.epilog.iter.check
  %.023.ph = phi ptr [ %0, %iter.check ], [ %ind.end34, %vec.epilog.iter.check ], [ %ind.end, %vec.epilog.middle.block ]
  br label %vec.epilog.scalar.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.vec33 = and i64 %13, -8
  %ind.end = getelementptr i8, ptr %0, i64 %n.vec33
  %broadcast.splatinsert37 = insertelement <8 x i8> poison, i8 %10, i64 0
  %broadcast.splat38 = shufflevector <8 x i8> %broadcast.splatinsert37, <8 x i8> poison, <8 x i32> zeroinitializer
  br label %vec.epilog.vector.body

vec.epilog.vector.body:                           ; preds = %vec.epilog.vector.body, %vec.epilog.ph
  %index35 = phi i64 [ %vec.epilog.resume.val, %vec.epilog.ph ], [ %index.next39, %vec.epilog.vector.body ]
  %next.gep36 = getelementptr i8, ptr %0, i64 %index35
  store <8 x i8> %broadcast.splat38, ptr %next.gep36, align 1, !tbaa !5
  %index.next39 = add nuw i64 %index35, 8
  %16 = icmp eq i64 %index.next39, %n.vec33
  br i1 %16, label %vec.epilog.middle.block, label %vec.epilog.vector.body, !llvm.loop !12

vec.epilog.middle.block:                          ; preds = %vec.epilog.vector.body
  %cmp.n40 = icmp eq i64 %13, %n.vec33
  br i1 %cmp.n40, label %.loopexit, label %vec.epilog.scalar.ph.preheader

17:                                               ; preds = %3
  %18 = and i32 %1, 255
  %narrow26 = mul nuw i32 %18, 16843009
  %19 = zext i32 %narrow26 to i64
  %20 = mul nuw i64 %19, 4294967297
  %21 = getelementptr inbounds i8, ptr %0, i64 %2
  %22 = icmp sgt i64 %2, 0
  br i1 %22, label %.lr.ph25.preheader, label %.loopexit

.lr.ph25.preheader:                               ; preds = %17
  %23 = add i64 %4, %2
  %24 = add i64 %4, 8
  %umax41 = tail call i64 @llvm.umax.i64(i64 %23, i64 %24)
  %25 = xor i64 %4, -1
  %26 = add i64 %umax41, %25
  %27 = lshr i64 %26, 3
  %28 = add nuw nsw i64 %27, 1
  %min.iters.check43 = icmp ult i64 %26, 24
  br i1 %min.iters.check43, label %.lr.ph25.preheader57, label %vector.ph44

vector.ph44:                                      ; preds = %.lr.ph25.preheader
  %n.vec46 = and i64 %28, 4611686018427387900
  %29 = shl i64 %n.vec46, 3
  %ind.end47 = getelementptr i8, ptr %0, i64 %29
  %broadcast.splatinsert53 = insertelement <2 x i64> poison, i64 %20, i64 0
  %broadcast.splat54 = shufflevector <2 x i64> %broadcast.splatinsert53, <2 x i64> poison, <2 x i32> zeroinitializer
  br label %vector.body49

vector.body49:                                    ; preds = %vector.body49, %vector.ph44
  %index50 = phi i64 [ 0, %vector.ph44 ], [ %index.next55, %vector.body49 ]
  %offset.idx = shl i64 %index50, 3
  %next.gep51 = getelementptr i8, ptr %0, i64 %offset.idx
  %30 = getelementptr i8, ptr %next.gep51, i64 16
  store <2 x i64> %broadcast.splat54, ptr %next.gep51, align 8, !tbaa !13
  store <2 x i64> %broadcast.splat54, ptr %30, align 8, !tbaa !13
  %index.next55 = add nuw i64 %index50, 4
  %31 = icmp eq i64 %index.next55, %n.vec46
  br i1 %31, label %middle.block42, label %vector.body49, !llvm.loop !15

middle.block42:                                   ; preds = %vector.body49
  %cmp.n56 = icmp eq i64 %28, %n.vec46
  br i1 %cmp.n56, label %.loopexit, label %.lr.ph25.preheader57

.lr.ph25.preheader57:                             ; preds = %middle.block42, %.lr.ph25.preheader
  %.02124.ph = phi ptr [ %0, %.lr.ph25.preheader ], [ %ind.end47, %middle.block42 ]
  br label %.lr.ph25

.lr.ph25:                                         ; preds = %.lr.ph25.preheader57, %.lr.ph25
  %.02124 = phi ptr [ %32, %.lr.ph25 ], [ %.02124.ph, %.lr.ph25.preheader57 ]
  %32 = getelementptr inbounds i8, ptr %.02124, i64 8
  store i64 %20, ptr %.02124, align 8, !tbaa !13
  %33 = icmp ult ptr %32, %21
  br i1 %33, label %.lr.ph25, label %.loopexit, !llvm.loop !16

vec.epilog.scalar.ph:                             ; preds = %vec.epilog.scalar.ph.preheader, %vec.epilog.scalar.ph
  %.023 = phi ptr [ %34, %vec.epilog.scalar.ph ], [ %.023.ph, %vec.epilog.scalar.ph.preheader ]
  %34 = getelementptr inbounds i8, ptr %.023, i64 1
  store i8 %10, ptr %.023, align 1, !tbaa !5
  %35 = icmp ult ptr %34, %8
  br i1 %35, label %vec.epilog.scalar.ph, label %.loopexit, !llvm.loop !17

.loopexit:                                        ; preds = %vec.epilog.scalar.ph, %.lr.ph25, %middle.block, %vec.epilog.middle.block, %middle.block42, %.preheader, %17
  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(write, 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, !11, !10}
!17 = distinct !{!17, !9, !11, !10}


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