; LLVM IR from QiaoLiuHit/LSOTB-TIR :: vlfeat-0.9.19/vl (hikmeans)

; 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 @vl_hikm_copy_subset(ptr noundef %0, ptr noundef %1, i64 noundef %2, i64 noundef %3, i32 noundef %4, ptr noundef %5) #0 {
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  %11 = alloca i32, align 4
  %12 = alloca ptr, align 8
  %13 = alloca i64, align 8
  %14 = alloca i64, align 8
  %15 = alloca ptr, align 8
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store i64 %2, ptr %9, align 8, !tbaa !9
  store i64 %3, ptr %10, align 8, !tbaa !9
  store i32 %4, ptr %11, align 4, !tbaa !11
  store ptr %5, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  store i64 0, ptr %14, align 8, !tbaa !9
  store i64 0, ptr %13, align 8, !tbaa !9
  br label %16

16:                                               ; preds = %31, %6
  %17 = load i64, ptr %13, align 8, !tbaa !9
  %18 = load i64, ptr %9, align 8, !tbaa !9
  %19 = icmp ult i64 %17, %18
  br i1 %19, label %20, label %34

20:                                               ; preds = %16
  %21 = load ptr, ptr %8, align 8, !tbaa !5
  %22 = load i64, ptr %13, align 8, !tbaa !9
  %23 = getelementptr inbounds i32, ptr %21, i64 %22
  %24 = load i32, ptr %23, align 4, !tbaa !11
  %25 = load i32, ptr %11, align 4, !tbaa !11
  %26 = icmp eq i32 %24, %25
  br i1 %26, label %27, label %30

27:                                               ; preds = %20
  %28 = load i64, ptr %14, align 8, !tbaa !9
  %29 = add i64 %28, 1
  store i64 %29, ptr %14, align 8, !tbaa !9
  br label %30

30:                                               ; preds = %27, %20
  br label %31

31:                                               ; preds = %30
  %32 = load i64, ptr %13, align 8, !tbaa !9
  %33 = add i64 %32, 1
  store i64 %33, ptr %13, align 8, !tbaa !9
  br label %16, !llvm.loop !13

34:                                               ; preds = %16
  %35 = load i64, ptr %14, align 8, !tbaa !9
  %36 = load ptr, ptr %12, align 8, !tbaa !5
  store i64 %35, ptr %36, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #4
  %37 = load i64, ptr %10, align 8, !tbaa !9
  %38 = mul i64 1, %37
  %39 = load i64, ptr %14, align 8, !tbaa !9
  %40 = mul i64 %38, %39
  %41 = call ptr @vl_malloc(i64 noundef %40)
  store ptr %41, ptr %15, align 8, !tbaa !5
  store i64 0, ptr %14, align 8, !tbaa !9
  store i64 0, ptr %13, align 8, !tbaa !9
  br label %42

42:                                               ; preds = %69, %34
  %43 = load i64, ptr %13, align 8, !tbaa !9
  %44 = load i64, ptr %9, align 8, !tbaa !9
  %45 = icmp ult i64 %43, %44
  br i1 %45, label %46, label %72

46:                                               ; preds = %42
  %47 = load ptr, ptr %8, align 8, !tbaa !5
  %48 = load i64, ptr %13, align 8, !tbaa !9
  %49 = getelementptr inbounds i32, ptr %47, i64 %48
  %50 = load i32, ptr %49, align 4, !tbaa !11
  %51 = load i32, ptr %11, align 4, !tbaa !11
  %52 = icmp eq i32 %50, %51
  br i1 %52, label %53, label %68

53:                                               ; preds = %46
  %54 = load ptr, ptr %15, align 8, !tbaa !5
  %55 = load i64, ptr %14, align 8, !tbaa !9
  %56 = load i64, ptr %10, align 8, !tbaa !9
  %57 = mul i64 %55, %56
  %58 = getelementptr inbounds i8, ptr %54, i64 %57
  %59 = load ptr, ptr %7, align 8, !tbaa !5
  %60 = load i64, ptr %13, align 8, !tbaa !9
  %61 = load i64, ptr %10, align 8, !tbaa !9
  %62 = mul i64 %60, %61
  %63 = getelementptr inbounds i8, ptr %59, i64 %62
  %64 = load i64, ptr %10, align 8, !tbaa !9
  %65 = mul i64 1, %64
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %58, ptr align 1 %63, i64 %65, i1 false)
  %66 = load i64, ptr %14, align 8, !tbaa !9
  %67 = add i64 %66, 1
  store i64 %67, ptr %14, align 8, !tbaa !9
  br label %68

68:                                               ; preds = %53, %46
  br label %69

69:                                               ; preds = %68
  %70 = load i64, ptr %13, align 8, !tbaa !9
  %71 = add i64 %70, 1
  store i64 %71, ptr %13, align 8, !tbaa !9
  br label %42, !llvm.loop !15

72:                                               ; preds = %42
  %73 = load i64, ptr %14, align 8, !tbaa !9
  %74 = load ptr, ptr %12, align 8, !tbaa !5
  store i64 %73, ptr %74, align 8, !tbaa !9
  %75 = load ptr, ptr %15, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  ret ptr %75
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

declare ptr @vl_malloc(i64 noundef) #2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

; 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 = { "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 #3 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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 long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !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: nounwind uwtable
define dso_local ptr @vl_hikm_copy_subset(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1, i64 noundef %2, i64 noundef %3, i32 noundef %4, ptr nocapture noundef writeonly %5) local_unnamed_addr #0 {
  %.not = icmp eq i64 %2, 0
  br i1 %.not, label %._crit_edge.thread, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %6
  %min.iters.check = icmp ult i64 %2, 4
  br i1 %min.iters.check, label %.lr.ph.preheader43, label %vector.ph

.lr.ph.preheader43:                               ; preds = %middle.block, %.lr.ph.preheader
  %.031.ph = phi i64 [ 0, %.lr.ph.preheader ], [ %n.vec, %middle.block ]
  %.02730.ph = phi i64 [ 0, %.lr.ph.preheader ], [ %16, %middle.block ]
  br label %.lr.ph

vector.ph:                                        ; preds = %.lr.ph.preheader
  %n.vec = and i64 %2, -4
  %broadcast.splatinsert = insertelement <2 x i32> poison, i32 %4, i64 0
  %broadcast.splat = shufflevector <2 x i32> %broadcast.splatinsert, <2 x i32> poison, <2 x i32> zeroinitializer
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %vec.phi = phi <2 x i64> [ zeroinitializer, %vector.ph ], [ %13, %vector.body ]
  %vec.phi41 = phi <2 x i64> [ zeroinitializer, %vector.ph ], [ %14, %vector.body ]
  %7 = getelementptr inbounds i32, ptr %1, i64 %index
  %8 = getelementptr inbounds i8, ptr %7, i64 8
  %wide.load = load <2 x i32>, ptr %7, align 4, !tbaa !5
  %wide.load42 = load <2 x i32>, ptr %8, align 4, !tbaa !5
  %9 = icmp eq <2 x i32> %wide.load, %broadcast.splat
  %10 = icmp eq <2 x i32> %wide.load42, %broadcast.splat
  %11 = zext <2 x i1> %9 to <2 x i64>
  %12 = zext <2 x i1> %10 to <2 x i64>
  %13 = add <2 x i64> %vec.phi, %11
  %14 = add <2 x i64> %vec.phi41, %12
  %index.next = add nuw i64 %index, 4
  %15 = icmp eq i64 %index.next, %n.vec
  br i1 %15, label %middle.block, label %vector.body, !llvm.loop !9

middle.block:                                     ; preds = %vector.body
  %bin.rdx = add <2 x i64> %14, %13
  %16 = tail call i64 @llvm.vector.reduce.add.v2i64(<2 x i64> %bin.rdx)
  %cmp.n = icmp eq i64 %n.vec, %2
  br i1 %cmp.n, label %.lr.ph35.preheader, label %.lr.ph.preheader43

._crit_edge.thread:                               ; preds = %6
  store i64 0, ptr %5, align 8, !tbaa !13
  %17 = tail call ptr @vl_malloc(i64 noundef 0) #4
  br label %._crit_edge36

.lr.ph:                                           ; preds = %.lr.ph.preheader43, %.lr.ph
  %.031 = phi i64 [ %22, %.lr.ph ], [ %.031.ph, %.lr.ph.preheader43 ]
  %.02730 = phi i64 [ %spec.select, %.lr.ph ], [ %.02730.ph, %.lr.ph.preheader43 ]
  %18 = getelementptr inbounds i32, ptr %1, i64 %.031
  %19 = load i32, ptr %18, align 4, !tbaa !5
  %20 = icmp eq i32 %19, %4
  %21 = zext i1 %20 to i64
  %spec.select = add i64 %.02730, %21
  %22 = add nuw i64 %.031, 1
  %exitcond.not = icmp eq i64 %22, %2
  br i1 %exitcond.not, label %.lr.ph35.preheader, label %.lr.ph, !llvm.loop !15

.lr.ph35.preheader:                               ; preds = %.lr.ph, %middle.block
  %spec.select.lcssa = phi i64 [ %16, %middle.block ], [ %spec.select, %.lr.ph ]
  store i64 %spec.select.lcssa, ptr %5, align 8, !tbaa !13
  %23 = mul i64 %spec.select.lcssa, %3
  %24 = tail call ptr @vl_malloc(i64 noundef %23) #4
  %xtraiter = and i64 %2, 1
  %25 = icmp eq i64 %2, 1
  br i1 %25, label %._crit_edge36.loopexit.unr-lcssa, label %.lr.ph35.preheader.new

.lr.ph35.preheader.new:                           ; preds = %.lr.ph35.preheader
  %unroll_iter = and i64 %2, -2
  br label %.lr.ph35

.lr.ph35:                                         ; preds = %45, %.lr.ph35.preheader.new
  %.133 = phi i64 [ 0, %.lr.ph35.preheader.new ], [ %46, %45 ]
  %.232 = phi i64 [ 0, %.lr.ph35.preheader.new ], [ %.3.1, %45 ]
  %niter = phi i64 [ 0, %.lr.ph35.preheader.new ], [ %niter.next.1, %45 ]
  %26 = getelementptr inbounds i32, ptr %1, i64 %.133
  %27 = load i32, ptr %26, align 4, !tbaa !5
  %28 = icmp eq i32 %27, %4
  br i1 %28, label %29, label %.lr.ph35.1

29:                                               ; preds = %.lr.ph35
  %30 = mul i64 %.232, %3
  %31 = getelementptr inbounds i8, ptr %24, i64 %30
  %32 = mul i64 %.133, %3
  %33 = getelementptr inbounds i8, ptr %0, i64 %32
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 1 %31, ptr align 1 %33, i64 %3, i1 false)
  %34 = add i64 %.232, 1
  br label %.lr.ph35.1

.lr.ph35.1:                                       ; preds = %.lr.ph35, %29
  %.3 = phi i64 [ %34, %29 ], [ %.232, %.lr.ph35 ]
  %35 = or disjoint i64 %.133, 1
  %36 = getelementptr inbounds i32, ptr %1, i64 %35
  %37 = load i32, ptr %36, align 4, !tbaa !5
  %38 = icmp eq i32 %37, %4
  br i1 %38, label %39, label %45

39:                                               ; preds = %.lr.ph35.1
  %40 = mul i64 %.3, %3
  %41 = getelementptr inbounds i8, ptr %24, i64 %40
  %42 = mul i64 %35, %3
  %43 = getelementptr inbounds i8, ptr %0, i64 %42
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 1 %41, ptr align 1 %43, i64 %3, i1 false)
  %44 = add i64 %.3, 1
  br label %45

45:                                               ; preds = %39, %.lr.ph35.1
  %.3.1 = phi i64 [ %44, %39 ], [ %.3, %.lr.ph35.1 ]
  %46 = add nuw i64 %.133, 2
  %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_edge36.loopexit.unr-lcssa, label %.lr.ph35, !llvm.loop !16

._crit_edge36.loopexit.unr-lcssa:                 ; preds = %45, %.lr.ph35.preheader
  %.3.lcssa.ph = phi i64 [ poison, %.lr.ph35.preheader ], [ %.3.1, %45 ]
  %.133.unr = phi i64 [ 0, %.lr.ph35.preheader ], [ %46, %45 ]
  %.232.unr = phi i64 [ 0, %.lr.ph35.preheader ], [ %.3.1, %45 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge36, label %.lr.ph35.epil

.lr.ph35.epil:                                    ; preds = %._crit_edge36.loopexit.unr-lcssa
  %47 = getelementptr inbounds i32, ptr %1, i64 %.133.unr
  %48 = load i32, ptr %47, align 4, !tbaa !5
  %49 = icmp eq i32 %48, %4
  br i1 %49, label %50, label %._crit_edge36

50:                                               ; preds = %.lr.ph35.epil
  %51 = mul i64 %.232.unr, %3
  %52 = getelementptr inbounds i8, ptr %24, i64 %51
  %53 = mul i64 %.133.unr, %3
  %54 = getelementptr inbounds i8, ptr %0, i64 %53
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 1 %52, ptr align 1 %54, i64 %3, i1 false)
  %55 = add i64 %.232.unr, 1
  br label %._crit_edge36

._crit_edge36:                                    ; preds = %._crit_edge36.loopexit.unr-lcssa, %50, %.lr.ph35.epil, %._crit_edge.thread
  %56 = phi ptr [ %17, %._crit_edge.thread ], [ %24, %.lr.ph35.epil ], [ %24, %50 ], [ %24, %._crit_edge36.loopexit.unr-lcssa ]
  %.2.lcssa = phi i64 [ 0, %._crit_edge.thread ], [ %.3.lcssa.ph, %._crit_edge36.loopexit.unr-lcssa ], [ %55, %50 ], [ %.232.unr, %.lr.ph35.epil ]
  store i64 %.2.lcssa, ptr %5, align 8, !tbaa !13
  ret ptr %56
}

declare ptr @vl_malloc(i64 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.vector.reduce.add.v2i64(<2 x i64>) #3

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 = { "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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { 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 = !{!"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 = !{!14, !14, i64 0}
!14 = !{!"long long", !7, i64 0}
!15 = distinct !{!15, !10, !12, !11}
!16 = distinct !{!16, !10}


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