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

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

21:                                               ; preds = %5
  %22 = load ptr, ptr %6, align 8, !tbaa !5
  %23 = load i64, ptr %22, align 8, !tbaa !9
  %24 = sub nsw i64 %23, 1
  %25 = load ptr, ptr %8, align 8, !tbaa !5
  %26 = load i64, ptr %25, align 8, !tbaa !9
  %27 = mul nsw i64 %24, %26
  %28 = add nsw i64 %27, 1
  store i64 %28, ptr %11, align 8, !tbaa !9
  %29 = load ptr, ptr %8, align 8, !tbaa !5
  %30 = load i64, ptr %29, align 8, !tbaa !9
  store i64 %30, ptr %12, align 8, !tbaa !9
  store i64 1, ptr %14, align 8, !tbaa !9
  br label %31

31:                                               ; preds = %97, %21
  %32 = load i64, ptr %12, align 8, !tbaa !9
  %33 = icmp slt i64 %32, 0
  br i1 %33, label %34, label %39

34:                                               ; preds = %31
  %35 = load i64, ptr %14, align 8, !tbaa !9
  %36 = load i64, ptr %11, align 8, !tbaa !9
  %37 = icmp sge i64 %35, %36
  %38 = zext i1 %37 to i32
  br label %44

39:                                               ; preds = %31
  %40 = load i64, ptr %14, align 8, !tbaa !9
  %41 = load i64, ptr %11, align 8, !tbaa !9
  %42 = icmp sle i64 %40, %41
  %43 = zext i1 %42 to i32
  br label %44

44:                                               ; preds = %39, %34
  %45 = phi i32 [ %38, %34 ], [ %43, %39 ]
  %46 = icmp ne i32 %45, 0
  br i1 %46, label %47, label %101

47:                                               ; preds = %44
  %48 = load ptr, ptr %7, align 8, !tbaa !5
  %49 = load i64, ptr %14, align 8, !tbaa !9
  %50 = getelementptr inbounds double, ptr %48, i64 %49
  %51 = load double, ptr %50, align 8, !tbaa !11
  %52 = fcmp une double %51, 0.000000e+00
  br i1 %52, label %53, label %96

53:                                               ; preds = %47
  %54 = load ptr, ptr %7, align 8, !tbaa !5
  %55 = load i64, ptr %14, align 8, !tbaa !9
  %56 = getelementptr inbounds double, ptr %54, i64 %55
  %57 = load double, ptr %56, align 8, !tbaa !11
  store double %57, ptr %13, align 8, !tbaa !11
  %58 = load double, ptr %13, align 8, !tbaa !11
  %59 = fcmp oge double %58, 0.000000e+00
  br i1 %59, label %60, label %62

60:                                               ; preds = %53
  %61 = load double, ptr %13, align 8, !tbaa !11
  br label %65

62:                                               ; preds = %53
  %63 = load double, ptr %13, align 8, !tbaa !11
  %64 = fneg double %63
  br label %65

65:                                               ; preds = %62, %60
  %66 = phi double [ %61, %60 ], [ %64, %62 ]
  store double %66, ptr %15, align 8, !tbaa !11
  %67 = load ptr, ptr %9, align 8, !tbaa !5
  %68 = load double, ptr %67, align 8, !tbaa !11
  %69 = load double, ptr %15, align 8, !tbaa !11
  %70 = fcmp olt double %68, %69
  br i1 %70, label %71, label %85

71:                                               ; preds = %65
  %72 = load ptr, ptr %9, align 8, !tbaa !5
  %73 = load double, ptr %72, align 8, !tbaa !11
  %74 = load double, ptr %15, align 8, !tbaa !11
  %75 = fdiv double %73, %74
  store double %75, ptr %13, align 8, !tbaa !11
  %76 = load ptr, ptr %10, align 8, !tbaa !5
  %77 = load double, ptr %76, align 8, !tbaa !11
  %78 = load double, ptr %13, align 8, !tbaa !11
  %79 = load double, ptr %13, align 8, !tbaa !11
  %80 = fmul double %78, %79
  %81 = call double @llvm.fmuladd.f64(double %77, double %80, double 1.000000e+00)
  %82 = load ptr, ptr %10, align 8, !tbaa !5
  store double %81, ptr %82, align 8, !tbaa !11
  %83 = load double, ptr %15, align 8, !tbaa !11
  %84 = load ptr, ptr %9, align 8, !tbaa !5
  store double %83, ptr %84, align 8, !tbaa !11
  br label %95

85:                                               ; preds = %65
  %86 = load double, ptr %15, align 8, !tbaa !11
  %87 = load ptr, ptr %9, align 8, !tbaa !5
  %88 = load double, ptr %87, align 8, !tbaa !11
  %89 = fdiv double %86, %88
  store double %89, ptr %13, align 8, !tbaa !11
  %90 = load double, ptr %13, align 8, !tbaa !11
  %91 = load double, ptr %13, align 8, !tbaa !11
  %92 = load ptr, ptr %10, align 8, !tbaa !5
  %93 = load double, ptr %92, align 8, !tbaa !11
  %94 = call double @llvm.fmuladd.f64(double %90, double %91, double %93)
  store double %94, ptr %92, align 8, !tbaa !11
  br label %95

95:                                               ; preds = %85, %71
  br label %96

96:                                               ; preds = %95, %47
  br label %97

97:                                               ; preds = %96
  %98 = load i64, ptr %12, align 8, !tbaa !9
  %99 = load i64, ptr %14, align 8, !tbaa !9
  %100 = add nsw i64 %99, %98
  store i64 %100, ptr %14, align 8, !tbaa !9
  br label %31, !llvm.loop !13

101:                                              ; preds = %44
  br label %102

102:                                              ; preds = %101, %5
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  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 speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #2

; 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { 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 @dlassq_(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1, ptr nocapture noundef readonly %2, ptr nocapture noundef %3, ptr nocapture noundef %4) local_unnamed_addr #0 {
  %6 = getelementptr inbounds i8, ptr %1, i64 -8
  %7 = load i64, ptr %0, align 8, !tbaa !5
  %8 = icmp sgt i64 %7, 0
  br i1 %8, label %9, label %.loopexit

9:                                                ; preds = %5
  %10 = add nsw i64 %7, -1
  %11 = load i64, ptr %2, align 8, !tbaa !5
  %12 = mul nsw i64 %11, %10
  %13 = add nsw i64 %12, 1
  %14 = icmp slt i64 %11, 0
  %15 = icmp slt i64 %12, 1
  %16 = icmp sgt i64 %12, -1
  %.in38 = select i1 %14, i1 %15, i1 %16
  br i1 %.in38, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %9, %34
  %.039 = phi i64 [ %35, %34 ], [ 1, %9 ]
  %17 = getelementptr inbounds double, ptr %6, i64 %.039
  %18 = load double, ptr %17, align 8, !tbaa !9
  %19 = fcmp une double %18, 0.000000e+00
  br i1 %19, label %20, label %34

20:                                               ; preds = %.lr.ph
  %21 = fcmp oge double %18, 0.000000e+00
  %22 = fneg double %18
  %23 = select i1 %21, double %18, double %22
  %24 = load double, ptr %3, align 8, !tbaa !9
  %25 = fcmp olt double %24, %23
  %26 = load double, ptr %4, align 8, !tbaa !9
  br i1 %25, label %27, label %31

27:                                               ; preds = %20
  %28 = fdiv double %24, %23
  %29 = fmul double %28, %28
  %30 = tail call double @llvm.fmuladd.f64(double %26, double %29, double 1.000000e+00)
  store double %30, ptr %4, align 8, !tbaa !9
  store double %23, ptr %3, align 8, !tbaa !9
  br label %34

31:                                               ; preds = %20
  %32 = fdiv double %23, %24
  %33 = tail call double @llvm.fmuladd.f64(double %32, double %32, double %26)
  store double %33, ptr %4, align 8, !tbaa !9
  br label %34

34:                                               ; preds = %.lr.ph, %31, %27
  %35 = add nsw i64 %.039, %11
  %36 = icmp sgt i64 %35, %12
  %37 = icmp sle i64 %35, %13
  %.in = select i1 %14, i1 %36, i1 %37
  br i1 %.in, label %.lr.ph, label %.loopexit, !llvm.loop !11

.loopexit:                                        ; preds = %34, %9, %5
  ret i32 0
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #1

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" }
attributes #1 = { mustprogress 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 = !{!"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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


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