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

; 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 @dlarscl2_(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4) #0 {
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i64, align 8
  %12 = alloca i64, align 8
  %13 = alloca i64, align 8
  %14 = alloca i64, align 8
  %15 = alloca i64, align 8
  %16 = alloca i64, align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !5
  store ptr %3, ptr %9, align 8, !tbaa !5
  store ptr %4, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #2
  %17 = load ptr, ptr %8, align 8, !tbaa !5
  %18 = getelementptr inbounds double, ptr %17, i32 -1
  store ptr %18, ptr %8, align 8, !tbaa !5
  %19 = load ptr, ptr %10, align 8, !tbaa !5
  %20 = load i64, ptr %19, align 8, !tbaa !9
  store i64 %20, ptr %11, align 8, !tbaa !9
  %21 = load i64, ptr %11, align 8, !tbaa !9
  %22 = add nsw i64 1, %21
  store i64 %22, ptr %12, align 8, !tbaa !9
  %23 = load i64, ptr %12, align 8, !tbaa !9
  %24 = load ptr, ptr %9, align 8, !tbaa !5
  %25 = sub i64 0, %23
  %26 = getelementptr inbounds double, ptr %24, i64 %25
  store ptr %26, ptr %9, align 8, !tbaa !5
  %27 = load ptr, ptr %7, align 8, !tbaa !5
  %28 = load i64, ptr %27, align 8, !tbaa !9
  store i64 %28, ptr %13, align 8, !tbaa !9
  store i64 1, ptr %16, align 8, !tbaa !9
  br label %29

29:                                               ; preds = %58, %5
  %30 = load i64, ptr %16, align 8, !tbaa !9
  %31 = load i64, ptr %13, align 8, !tbaa !9
  %32 = icmp sle i64 %30, %31
  br i1 %32, label %33, label %61

33:                                               ; preds = %29
  %34 = load ptr, ptr %6, align 8, !tbaa !5
  %35 = load i64, ptr %34, align 8, !tbaa !9
  store i64 %35, ptr %14, align 8, !tbaa !9
  store i64 1, ptr %15, align 8, !tbaa !9
  br label %36

36:                                               ; preds = %54, %33
  %37 = load i64, ptr %15, align 8, !tbaa !9
  %38 = load i64, ptr %14, align 8, !tbaa !9
  %39 = icmp sle i64 %37, %38
  br i1 %39, label %40, label %57

40:                                               ; preds = %36
  %41 = load ptr, ptr %8, align 8, !tbaa !5
  %42 = load i64, ptr %15, align 8, !tbaa !9
  %43 = getelementptr inbounds double, ptr %41, i64 %42
  %44 = load double, ptr %43, align 8, !tbaa !11
  %45 = load ptr, ptr %9, align 8, !tbaa !5
  %46 = load i64, ptr %15, align 8, !tbaa !9
  %47 = load i64, ptr %16, align 8, !tbaa !9
  %48 = load i64, ptr %11, align 8, !tbaa !9
  %49 = mul nsw i64 %47, %48
  %50 = add nsw i64 %46, %49
  %51 = getelementptr inbounds double, ptr %45, i64 %50
  %52 = load double, ptr %51, align 8, !tbaa !11
  %53 = fdiv double %52, %44
  store double %53, ptr %51, align 8, !tbaa !11
  br label %54

54:                                               ; preds = %40
  %55 = load i64, ptr %15, align 8, !tbaa !9
  %56 = add nsw i64 %55, 1
  store i64 %56, ptr %15, align 8, !tbaa !9
  br label %36, !llvm.loop !13

57:                                               ; preds = %36
  br label %58

58:                                               ; preds = %57
  %59 = load i64, ptr %16, align 8, !tbaa !9
  %60 = add nsw i64 %59, 1
  store i64 %60, ptr %16, align 8, !tbaa !9
  br label %29, !llvm.loop !15

61:                                               ; preds = %29
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #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"}
!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: nofree norecurse nosync nounwind memory(argmem: readwrite) uwtable
define dso_local noundef i32 @dlarscl2_(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1, ptr nocapture noundef readonly %2, ptr nocapture noundef %3, ptr nocapture noundef readonly %4) local_unnamed_addr #0 {
  %6 = getelementptr inbounds i8, ptr %2, i64 -8
  %7 = load i64, ptr %4, align 8, !tbaa !5
  %8 = xor i64 %7, -1
  %9 = getelementptr inbounds double, ptr %3, i64 %8
  %10 = load i64, ptr %1, align 8, !tbaa !5
  %.not22 = icmp slt i64 %10, 1
  br i1 %.not22, label %._crit_edge26, label %.lr.ph25

.lr.ph25:                                         ; preds = %5
  %11 = load i64, ptr %0, align 8, !tbaa !5
  %.not1920 = icmp slt i64 %11, 1
  br i1 %.not1920, label %._crit_edge26, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %.lr.ph25
  %12 = add nuw i64 %10, 2305843009213693951
  %13 = mul i64 %7, %12
  %14 = shl i64 %11, 3
  %15 = add i64 %13, %11
  %16 = shl i64 %15, 3
  %scevgep = getelementptr i8, ptr %3, i64 %16
  %scevgep29 = getelementptr i8, ptr %2, i64 %14
  %17 = add nuw i64 %11, 1
  %min.iters.check = icmp eq i64 %11, 1
  %bound0 = icmp ugt ptr %scevgep29, %3
  %bound1 = icmp ugt ptr %scevgep, %2
  %found.conflict = and i1 %bound0, %bound1
  %.mask = and i64 %7, 1152921504606846976
  %stride.check = icmp ne i64 %.mask, 0
  %18 = or i1 %found.conflict, %stride.check
  %n.vec = and i64 %11, 9223372036854775806
  %ind.end = or i64 %11, 1
  %cmp.n = icmp eq i64 %11, %n.vec
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %._crit_edge
  %.023 = phi i64 [ %51, %._crit_edge ], [ 1, %.lr.ph.preheader ]
  %19 = mul nsw i64 %.023, %7
  %invariant.gep = getelementptr double, ptr %9, i64 %19
  %brmerge = select i1 %min.iters.check, i1 true, i1 %18
  br i1 %brmerge, label %scalar.ph.preheader, label %vector.body

vector.body:                                      ; preds = %.lr.ph, %vector.body
  %index = phi i64 [ %index.next, %vector.body ], [ 0, %.lr.ph ]
  %offset.idx = or disjoint i64 %index, 1
  %20 = getelementptr double, ptr %2, i64 %index
  %wide.load = load <2 x double>, ptr %20, align 8, !tbaa !9, !alias.scope !11
  %21 = getelementptr double, ptr %invariant.gep, i64 %offset.idx
  %wide.load30 = load <2 x double>, ptr %21, align 8, !tbaa !9, !alias.scope !14, !noalias !11
  %22 = fdiv <2 x double> %wide.load30, %wide.load
  store <2 x double> %22, ptr %21, align 8, !tbaa !9, !alias.scope !14, !noalias !11
  %index.next = add nuw i64 %index, 2
  %23 = icmp eq i64 %index.next, %n.vec
  br i1 %23, label %middle.block, label %vector.body, !llvm.loop !16

middle.block:                                     ; preds = %vector.body
  br i1 %cmp.n, label %._crit_edge, label %scalar.ph.preheader

scalar.ph.preheader:                              ; preds = %.lr.ph, %middle.block
  %.01821.ph = phi i64 [ 1, %.lr.ph ], [ %ind.end, %middle.block ]
  %24 = sub i64 %17, %.01821.ph
  %25 = sub i64 %11, %.01821.ph
  %xtraiter = and i64 %24, 3
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %scalar.ph.prol.loopexit, label %scalar.ph.prol

scalar.ph.prol:                                   ; preds = %scalar.ph.preheader, %scalar.ph.prol
  %.01821.prol = phi i64 [ %30, %scalar.ph.prol ], [ %.01821.ph, %scalar.ph.preheader ]
  %prol.iter = phi i64 [ %prol.iter.next, %scalar.ph.prol ], [ 0, %scalar.ph.preheader ]
  %26 = getelementptr inbounds double, ptr %6, i64 %.01821.prol
  %27 = load double, ptr %26, align 8, !tbaa !9
  %gep.prol = getelementptr double, ptr %invariant.gep, i64 %.01821.prol
  %28 = load double, ptr %gep.prol, align 8, !tbaa !9
  %29 = fdiv double %28, %27
  store double %29, ptr %gep.prol, align 8, !tbaa !9
  %30 = add nuw i64 %.01821.prol, 1
  %prol.iter.next = add i64 %prol.iter, 1
  %prol.iter.cmp.not = icmp eq i64 %prol.iter.next, %xtraiter
  br i1 %prol.iter.cmp.not, label %scalar.ph.prol.loopexit, label %scalar.ph.prol, !llvm.loop !20

scalar.ph.prol.loopexit:                          ; preds = %scalar.ph.prol, %scalar.ph.preheader
  %.01821.unr = phi i64 [ %.01821.ph, %scalar.ph.preheader ], [ %30, %scalar.ph.prol ]
  %31 = icmp ult i64 %25, 3
  br i1 %31, label %._crit_edge, label %scalar.ph.preheader.new

scalar.ph.preheader.new:                          ; preds = %scalar.ph.prol.loopexit
  %invariant.gep31 = getelementptr i8, ptr %invariant.gep, i64 8
  br label %scalar.ph

scalar.ph:                                        ; preds = %scalar.ph, %scalar.ph.preheader.new
  %.01821 = phi i64 [ %.01821.unr, %scalar.ph.preheader.new ], [ %50, %scalar.ph ]
  %32 = getelementptr inbounds double, ptr %6, i64 %.01821
  %33 = load double, ptr %32, align 8, !tbaa !9
  %gep = getelementptr double, ptr %invariant.gep, i64 %.01821
  %34 = load double, ptr %gep, align 8, !tbaa !9
  %35 = fdiv double %34, %33
  store double %35, ptr %gep, align 8, !tbaa !9
  %36 = getelementptr double, ptr %2, i64 %.01821
  %37 = load double, ptr %36, align 8, !tbaa !9
  %gep32 = getelementptr double, ptr %invariant.gep31, i64 %.01821
  %38 = load double, ptr %gep32, align 8, !tbaa !9
  %39 = fdiv double %38, %37
  store double %39, ptr %gep32, align 8, !tbaa !9
  %40 = add nuw i64 %.01821, 2
  %41 = getelementptr inbounds double, ptr %6, i64 %40
  %42 = load double, ptr %41, align 8, !tbaa !9
  %gep.2 = getelementptr double, ptr %invariant.gep, i64 %40
  %43 = load double, ptr %gep.2, align 8, !tbaa !9
  %44 = fdiv double %43, %42
  store double %44, ptr %gep.2, align 8, !tbaa !9
  %45 = add nuw i64 %.01821, 3
  %46 = getelementptr inbounds double, ptr %6, i64 %45
  %47 = load double, ptr %46, align 8, !tbaa !9
  %gep.3 = getelementptr double, ptr %invariant.gep, i64 %45
  %48 = load double, ptr %gep.3, align 8, !tbaa !9
  %49 = fdiv double %48, %47
  store double %49, ptr %gep.3, align 8, !tbaa !9
  %50 = add nuw i64 %.01821, 4
  %exitcond.not.3 = icmp eq i64 %45, %11
  br i1 %exitcond.not.3, label %._crit_edge, label %scalar.ph, !llvm.loop !22

._crit_edge:                                      ; preds = %scalar.ph.prol.loopexit, %scalar.ph, %middle.block
  %51 = add nuw i64 %.023, 1
  %exitcond28.not = icmp eq i64 %.023, %10
  br i1 %exitcond28.not, label %._crit_edge26, label %.lr.ph, !llvm.loop !23

._crit_edge26:                                    ; preds = %._crit_edge, %.lr.ph25, %5
  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 = distinct !{!16, !17, !18, !19}
!17 = !{!"llvm.loop.mustprogress"}
!18 = !{!"llvm.loop.isvectorized", i32 1}
!19 = !{!"llvm.loop.unroll.runtime.disable"}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.unroll.disable"}
!22 = distinct !{!22, !17, !18}
!23 = distinct !{!23, !17}


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