; LLVM IR from niuyishuai/PDCABB :: LAPACK_BLAS/LAPACK (dla_wwaddw)

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

20:                                               ; preds = %62, %4
  %21 = load i64, ptr %10, align 8, !tbaa !9
  %22 = load i64, ptr %9, align 8, !tbaa !9
  %23 = icmp sle i64 %21, %22
  br i1 %23, label %24, label %65

24:                                               ; preds = %20
  %25 = load ptr, ptr %6, align 8, !tbaa !5
  %26 = load i64, ptr %10, align 8, !tbaa !9
  %27 = getelementptr inbounds double, ptr %25, i64 %26
  %28 = load double, ptr %27, align 8, !tbaa !11
  %29 = load ptr, ptr %8, align 8, !tbaa !5
  %30 = load i64, ptr %10, align 8, !tbaa !9
  %31 = getelementptr inbounds double, ptr %29, i64 %30
  %32 = load double, ptr %31, align 8, !tbaa !11
  %33 = fadd double %28, %32
  store double %33, ptr %11, align 8, !tbaa !11
  %34 = load double, ptr %11, align 8, !tbaa !11
  %35 = load double, ptr %11, align 8, !tbaa !11
  %36 = fadd double %34, %35
  %37 = load double, ptr %11, align 8, !tbaa !11
  %38 = fsub double %36, %37
  store double %38, ptr %11, align 8, !tbaa !11
  %39 = load ptr, ptr %6, align 8, !tbaa !5
  %40 = load i64, ptr %10, align 8, !tbaa !9
  %41 = getelementptr inbounds double, ptr %39, i64 %40
  %42 = load double, ptr %41, align 8, !tbaa !11
  %43 = load double, ptr %11, align 8, !tbaa !11
  %44 = fsub double %42, %43
  %45 = load ptr, ptr %8, align 8, !tbaa !5
  %46 = load i64, ptr %10, align 8, !tbaa !9
  %47 = getelementptr inbounds double, ptr %45, i64 %46
  %48 = load double, ptr %47, align 8, !tbaa !11
  %49 = fadd double %44, %48
  %50 = load ptr, ptr %7, align 8, !tbaa !5
  %51 = load i64, ptr %10, align 8, !tbaa !9
  %52 = getelementptr inbounds double, ptr %50, i64 %51
  %53 = load double, ptr %52, align 8, !tbaa !11
  %54 = fadd double %49, %53
  %55 = load ptr, ptr %7, align 8, !tbaa !5
  %56 = load i64, ptr %10, align 8, !tbaa !9
  %57 = getelementptr inbounds double, ptr %55, i64 %56
  store double %54, ptr %57, align 8, !tbaa !11
  %58 = load double, ptr %11, align 8, !tbaa !11
  %59 = load ptr, ptr %6, align 8, !tbaa !5
  %60 = load i64, ptr %10, align 8, !tbaa !9
  %61 = getelementptr inbounds double, ptr %59, i64 %60
  store double %58, ptr %61, align 8, !tbaa !11
  br label %62

62:                                               ; preds = %24
  %63 = load i64, ptr %10, align 8, !tbaa !9
  %64 = add nsw i64 %63, 1
  store i64 %64, ptr %10, align 8, !tbaa !9
  br label %20, !llvm.loop !13

65:                                               ; preds = %20
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #2
  ret i32 0
}

; 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 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


; 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(argmem: readwrite) uwtable
define dso_local noundef i32 @dla_wwaddw__(ptr nocapture noundef readonly %0, ptr nocapture noundef %1, ptr nocapture noundef %2, ptr nocapture noundef readonly %3) local_unnamed_addr #0 {
  %5 = getelementptr inbounds i8, ptr %3, i64 -8
  %6 = getelementptr inbounds i8, ptr %2, i64 -8
  %7 = getelementptr inbounds i8, ptr %1, i64 -8
  %8 = load i64, ptr %0, align 8, !tbaa !5
  %.not25 = icmp slt i64 %8, 1
  br i1 %.not25, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %4
  %min.iters.check = icmp ult i64 %8, 8
  br i1 %min.iters.check, label %.lr.ph.preheader38, label %vector.memcheck

vector.memcheck:                                  ; preds = %.lr.ph.preheader
  %9 = shl i64 %8, 3
  %scevgep = getelementptr i8, ptr %2, i64 %9
  %scevgep27 = getelementptr i8, ptr %1, i64 %9
  %scevgep28 = getelementptr i8, ptr %3, i64 %9
  %bound0 = icmp ugt ptr %scevgep27, %2
  %bound1 = icmp ugt ptr %scevgep, %1
  %found.conflict = and i1 %bound0, %bound1
  %bound029 = icmp ugt ptr %scevgep28, %2
  %bound130 = icmp ugt ptr %scevgep, %3
  %found.conflict31 = and i1 %bound029, %bound130
  %conflict.rdx = or i1 %found.conflict, %found.conflict31
  %bound032 = icmp ugt ptr %scevgep28, %1
  %bound133 = icmp ugt ptr %scevgep27, %3
  %found.conflict34 = and i1 %bound032, %bound133
  %conflict.rdx35 = or i1 %conflict.rdx, %found.conflict34
  br i1 %conflict.rdx35, label %.lr.ph.preheader38, label %vector.ph

vector.ph:                                        ; preds = %vector.memcheck
  %n.vec = and i64 %8, 9223372036854775806
  %ind.end = or i64 %8, 1
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %10 = getelementptr double, ptr %1, i64 %index
  %wide.load = load <2 x double>, ptr %10, align 8, !tbaa !9, !alias.scope !11, !noalias !14
  %11 = getelementptr double, ptr %3, i64 %index
  %wide.load36 = load <2 x double>, ptr %11, align 8, !tbaa !9, !alias.scope !14
  %12 = fadd <2 x double> %wide.load, %wide.load36
  %13 = fadd <2 x double> %12, %12
  %14 = fsub <2 x double> %13, %12
  %15 = fsub <2 x double> %wide.load, %14
  %16 = fadd <2 x double> %wide.load36, %15
  %17 = getelementptr double, ptr %2, i64 %index
  %wide.load37 = load <2 x double>, ptr %17, align 8, !tbaa !9, !alias.scope !16, !noalias !18
  %18 = fadd <2 x double> %wide.load37, %16
  store <2 x double> %18, ptr %17, align 8, !tbaa !9, !alias.scope !16, !noalias !18
  store <2 x double> %14, ptr %10, align 8, !tbaa !9, !alias.scope !11, !noalias !14
  %index.next = add nuw i64 %index, 2
  %19 = icmp eq i64 %index.next, %n.vec
  br i1 %19, label %middle.block, label %vector.body, !llvm.loop !19

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %8, %n.vec
  br i1 %cmp.n, label %._crit_edge, label %.lr.ph.preheader38

.lr.ph.preheader38:                               ; preds = %middle.block, %vector.memcheck, %.lr.ph.preheader
  %.026.ph = phi i64 [ 1, %vector.memcheck ], [ 1, %.lr.ph.preheader ], [ %ind.end, %middle.block ]
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader38, %.lr.ph
  %.026 = phi i64 [ %32, %.lr.ph ], [ %.026.ph, %.lr.ph.preheader38 ]
  %20 = getelementptr inbounds double, ptr %7, i64 %.026
  %21 = load double, ptr %20, align 8, !tbaa !9
  %22 = getelementptr inbounds double, ptr %5, i64 %.026
  %23 = load double, ptr %22, align 8, !tbaa !9
  %24 = fadd double %21, %23
  %25 = fadd double %24, %24
  %26 = fsub double %25, %24
  %27 = fsub double %21, %26
  %28 = fadd double %23, %27
  %29 = getelementptr inbounds double, ptr %6, i64 %.026
  %30 = load double, ptr %29, align 8, !tbaa !9
  %31 = fadd double %30, %28
  store double %31, ptr %29, align 8, !tbaa !9
  store double %26, ptr %20, align 8, !tbaa !9
  %32 = add nuw i64 %.026, 1
  %exitcond.not = icmp eq i64 %.026, %8
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !23

._crit_edge:                                      ; preds = %.lr.ph, %middle.block, %4
  ret i32 0
}

attributes #0 = { nofree norecurse nosync nounwind memory(argmem: readwrite) 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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = !{!12}
!12 = distinct !{!12, !13}
!13 = distinct !{!13, !"LVerDomain"}
!14 = !{!15}
!15 = distinct !{!15, !13}
!16 = !{!17}
!17 = distinct !{!17, !13}
!18 = !{!12, !15}
!19 = distinct !{!19, !20, !21, !22}
!20 = !{!"llvm.loop.mustprogress"}
!21 = !{!"llvm.loop.isvectorized", i32 1}
!22 = !{!"llvm.loop.unroll.runtime.disable"}
!23 = distinct !{!23, !20, !21}


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