; LLVM IR from OpenMathLib/OpenBLAS :: lapack-netlib/SRC (zlassq)

; 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"

%struct.doublecomplex = type { double, double }

; Function Attrs: nounwind uwtable
define dso_local void @zlassq_(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 i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca double, align 8
  %15 = alloca double, align 8
  %16 = alloca i32, align 4
  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 4, ptr %11) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #5
  %17 = load ptr, ptr %7, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.doublecomplex, ptr %17, i32 -1
  store ptr %18, ptr %7, align 8, !tbaa !5
  %19 = load ptr, ptr %6, align 8, !tbaa !5
  %20 = load i32, ptr %19, align 4, !tbaa !9
  %21 = icmp sgt i32 %20, 0
  br i1 %21, label %22, label %158

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

32:                                               ; preds = %153, %22
  %33 = load i32, ptr %12, align 4, !tbaa !9
  %34 = icmp slt i32 %33, 0
  br i1 %34, label %35, label %40

35:                                               ; preds = %32
  %36 = load i32, ptr %16, align 4, !tbaa !9
  %37 = load i32, ptr %11, align 4, !tbaa !9
  %38 = icmp sge i32 %36, %37
  %39 = zext i1 %38 to i32
  br label %45

40:                                               ; preds = %32
  %41 = load i32, ptr %16, align 4, !tbaa !9
  %42 = load i32, ptr %11, align 4, !tbaa !9
  %43 = icmp sle i32 %41, %42
  %44 = zext i1 %43 to i32
  br label %45

45:                                               ; preds = %40, %35
  %46 = phi i32 [ %39, %35 ], [ %44, %40 ]
  %47 = icmp ne i32 %46, 0
  br i1 %47, label %48, label %157

48:                                               ; preds = %45
  %49 = load i32, ptr %16, align 4, !tbaa !9
  store i32 %49, ptr %13, align 4, !tbaa !9
  %50 = load ptr, ptr %7, align 8, !tbaa !5
  %51 = load i32, ptr %13, align 4, !tbaa !9
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds %struct.doublecomplex, ptr %50, i64 %52
  %54 = getelementptr inbounds %struct.doublecomplex, ptr %53, i32 0, i32 0
  %55 = load double, ptr %54, align 8, !tbaa !11
  store double %55, ptr %14, align 8, !tbaa !14
  %56 = load double, ptr %14, align 8, !tbaa !14
  %57 = fcmp oge double %56, 0.000000e+00
  br i1 %57, label %58, label %60

58:                                               ; preds = %48
  %59 = load double, ptr %14, align 8, !tbaa !14
  br label %63

60:                                               ; preds = %48
  %61 = load double, ptr %14, align 8, !tbaa !14
  %62 = fneg double %61
  br label %63

63:                                               ; preds = %60, %58
  %64 = phi double [ %59, %58 ], [ %62, %60 ]
  store double %64, ptr %15, align 8, !tbaa !14
  %65 = load double, ptr %15, align 8, !tbaa !14
  %66 = fcmp ogt double %65, 0.000000e+00
  br i1 %66, label %70, label %67

67:                                               ; preds = %63
  %68 = call i32 @disnan_(ptr noundef %15)
  %69 = icmp ne i32 %68, 0
  br i1 %69, label %70, label %100

70:                                               ; preds = %67, %63
  %71 = load ptr, ptr %9, align 8, !tbaa !5
  %72 = load double, ptr %71, align 8, !tbaa !14
  %73 = load double, ptr %15, align 8, !tbaa !14
  %74 = fcmp olt double %72, %73
  br i1 %74, label %75, label %89

75:                                               ; preds = %70
  %76 = load ptr, ptr %9, align 8, !tbaa !5
  %77 = load double, ptr %76, align 8, !tbaa !14
  %78 = load double, ptr %15, align 8, !tbaa !14
  %79 = fdiv double %77, %78
  store double %79, ptr %14, align 8, !tbaa !14
  %80 = load ptr, ptr %10, align 8, !tbaa !5
  %81 = load double, ptr %80, align 8, !tbaa !14
  %82 = load double, ptr %14, align 8, !tbaa !14
  %83 = load double, ptr %14, align 8, !tbaa !14
  %84 = fmul double %82, %83
  %85 = call double @llvm.fmuladd.f64(double %81, double %84, double 1.000000e+00)
  %86 = load ptr, ptr %10, align 8, !tbaa !5
  store double %85, ptr %86, align 8, !tbaa !14
  %87 = load double, ptr %15, align 8, !tbaa !14
  %88 = load ptr, ptr %9, align 8, !tbaa !5
  store double %87, ptr %88, align 8, !tbaa !14
  br label %99

89:                                               ; preds = %70
  %90 = load double, ptr %15, align 8, !tbaa !14
  %91 = load ptr, ptr %9, align 8, !tbaa !5
  %92 = load double, ptr %91, align 8, !tbaa !14
  %93 = fdiv double %90, %92
  store double %93, ptr %14, align 8, !tbaa !14
  %94 = load double, ptr %14, align 8, !tbaa !14
  %95 = load double, ptr %14, align 8, !tbaa !14
  %96 = load ptr, ptr %10, align 8, !tbaa !5
  %97 = load double, ptr %96, align 8, !tbaa !14
  %98 = call double @llvm.fmuladd.f64(double %94, double %95, double %97)
  store double %98, ptr %96, align 8, !tbaa !14
  br label %99

99:                                               ; preds = %89, %75
  br label %100

100:                                              ; preds = %99, %67
  %101 = load ptr, ptr %7, align 8, !tbaa !5
  %102 = load i32, ptr %16, align 4, !tbaa !9
  %103 = sext i32 %102 to i64
  %104 = getelementptr inbounds %struct.doublecomplex, ptr %101, i64 %103
  %105 = call { double, double } @Cd(ptr noundef %104)
  %106 = extractvalue { double, double } %105, 0
  %107 = extractvalue { double, double } %105, 1
  store double %107, ptr %14, align 8, !tbaa !14
  %108 = load double, ptr %14, align 8, !tbaa !14
  %109 = fcmp oge double %108, 0.000000e+00
  br i1 %109, label %110, label %112

110:                                              ; preds = %100
  %111 = load double, ptr %14, align 8, !tbaa !14
  br label %115

112:                                              ; preds = %100
  %113 = load double, ptr %14, align 8, !tbaa !14
  %114 = fneg double %113
  br label %115

115:                                              ; preds = %112, %110
  %116 = phi double [ %111, %110 ], [ %114, %112 ]
  store double %116, ptr %15, align 8, !tbaa !14
  %117 = load double, ptr %15, align 8, !tbaa !14
  %118 = fcmp ogt double %117, 0.000000e+00
  br i1 %118, label %122, label %119

119:                                              ; preds = %115
  %120 = call i32 @disnan_(ptr noundef %15)
  %121 = icmp ne i32 %120, 0
  br i1 %121, label %122, label %152

122:                                              ; preds = %119, %115
  %123 = load ptr, ptr %9, align 8, !tbaa !5
  %124 = load double, ptr %123, align 8, !tbaa !14
  %125 = load double, ptr %15, align 8, !tbaa !14
  %126 = fcmp olt double %124, %125
  br i1 %126, label %127, label %141

127:                                              ; preds = %122
  %128 = load ptr, ptr %9, align 8, !tbaa !5
  %129 = load double, ptr %128, align 8, !tbaa !14
  %130 = load double, ptr %15, align 8, !tbaa !14
  %131 = fdiv double %129, %130
  store double %131, ptr %14, align 8, !tbaa !14
  %132 = load ptr, ptr %10, align 8, !tbaa !5
  %133 = load double, ptr %132, align 8, !tbaa !14
  %134 = load double, ptr %14, align 8, !tbaa !14
  %135 = load double, ptr %14, align 8, !tbaa !14
  %136 = fmul double %134, %135
  %137 = call double @llvm.fmuladd.f64(double %133, double %136, double 1.000000e+00)
  %138 = load ptr, ptr %10, align 8, !tbaa !5
  store double %137, ptr %138, align 8, !tbaa !14
  %139 = load double, ptr %15, align 8, !tbaa !14
  %140 = load ptr, ptr %9, align 8, !tbaa !5
  store double %139, ptr %140, align 8, !tbaa !14
  br label %151

141:                                              ; preds = %122
  %142 = load double, ptr %15, align 8, !tbaa !14
  %143 = load ptr, ptr %9, align 8, !tbaa !5
  %144 = load double, ptr %143, align 8, !tbaa !14
  %145 = fdiv double %142, %144
  store double %145, ptr %14, align 8, !tbaa !14
  %146 = load double, ptr %14, align 8, !tbaa !14
  %147 = load double, ptr %14, align 8, !tbaa !14
  %148 = load ptr, ptr %10, align 8, !tbaa !5
  %149 = load double, ptr %148, align 8, !tbaa !14
  %150 = call double @llvm.fmuladd.f64(double %146, double %147, double %149)
  store double %150, ptr %148, align 8, !tbaa !14
  br label %151

151:                                              ; preds = %141, %127
  br label %152

152:                                              ; preds = %151, %119
  br label %153

153:                                              ; preds = %152
  %154 = load i32, ptr %12, align 4, !tbaa !9
  %155 = load i32, ptr %16, align 4, !tbaa !9
  %156 = add nsw i32 %155, %154
  store i32 %156, ptr %16, align 4, !tbaa !9
  br label %32, !llvm.loop !15

157:                                              ; preds = %45
  br label %158

158:                                              ; preds = %157, %5
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  ret void
}

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

declare i32 @disnan_(ptr noundef) #2

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden { double, double } @Cd(ptr noundef) #4

; 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 nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { inlinehint 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 #5 = { 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, !13, i64 0}
!12 = !{!"", !13, i64 0, !13, i64 8}
!13 = !{!"double", !7, i64 0}
!14 = !{!13, !13, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"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"

%struct.doublecomplex = type { double, double }

; Function Attrs: nounwind uwtable
define dso_local void @zlassq_(ptr nocapture noundef readonly %0, ptr noundef %1, ptr nocapture noundef readonly %2, ptr nocapture noundef %3, ptr nocapture noundef %4) local_unnamed_addr #0 {
  %6 = alloca double, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #5
  %7 = getelementptr inbounds i8, ptr %1, i64 -16
  %8 = load i32, ptr %0, align 4, !tbaa !5
  %9 = icmp sgt i32 %8, 0
  br i1 %9, label %10, label %.loopexit

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

.lr.ph.preheader:                                 ; preds = %10
  %17 = add nsw i32 %13, 1
  %18 = sext i32 %12 to i64
  %19 = sext i32 %13 to i64
  %20 = sext i32 %17 to i64
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %62
  %indvars.iv = phi i64 [ 1, %.lr.ph.preheader ], [ %indvars.iv.next, %62 ]
  %21 = getelementptr inbounds %struct.doublecomplex, ptr %7, i64 %indvars.iv
  %22 = load double, ptr %21, align 8, !tbaa !9
  %23 = fcmp oge double %22, 0.000000e+00
  %24 = fneg double %22
  %25 = select i1 %23, double %22, double %24
  store double %25, ptr %6, align 8, !tbaa !12
  %26 = fcmp ogt double %25, 0.000000e+00
  br i1 %26, label %29, label %27

27:                                               ; preds = %.lr.ph
  %28 = call i32 @disnan_(ptr noundef nonnull %6) #5
  %.not = icmp eq i32 %28, 0
  br i1 %.not, label %41, label %._crit_edge

._crit_edge:                                      ; preds = %27
  %.pre = load double, ptr %6, align 8, !tbaa !12
  br label %29

29:                                               ; preds = %._crit_edge, %.lr.ph
  %30 = phi double [ %.pre, %._crit_edge ], [ %25, %.lr.ph ]
  %31 = load double, ptr %3, align 8, !tbaa !12
  %32 = fcmp olt double %31, %30
  %33 = load double, ptr %4, align 8, !tbaa !12
  br i1 %32, label %34, label %38

34:                                               ; preds = %29
  %35 = fdiv double %31, %30
  %36 = fmul double %35, %35
  %37 = call double @llvm.fmuladd.f64(double %33, double %36, double 1.000000e+00)
  store double %37, ptr %4, align 8, !tbaa !12
  store double %30, ptr %3, align 8, !tbaa !12
  br label %41

38:                                               ; preds = %29
  %39 = fdiv double %30, %31
  %40 = call double @llvm.fmuladd.f64(double %39, double %39, double %33)
  store double %40, ptr %4, align 8, !tbaa !12
  br label %41

41:                                               ; preds = %34, %38, %27
  %42 = call { double, double } @Cd(ptr noundef nonnull %21)
  %43 = extractvalue { double, double } %42, 1
  %44 = fcmp oge double %43, 0.000000e+00
  %45 = fneg double %43
  %46 = select i1 %44, double %43, double %45
  store double %46, ptr %6, align 8, !tbaa !12
  %47 = fcmp ogt double %46, 0.000000e+00
  br i1 %47, label %50, label %48

48:                                               ; preds = %41
  %49 = call i32 @disnan_(ptr noundef nonnull %6) #5
  %.not52 = icmp eq i32 %49, 0
  br i1 %.not52, label %62, label %._crit_edge56

._crit_edge56:                                    ; preds = %48
  %.pre57 = load double, ptr %6, align 8, !tbaa !12
  br label %50

50:                                               ; preds = %._crit_edge56, %41
  %51 = phi double [ %.pre57, %._crit_edge56 ], [ %46, %41 ]
  %52 = load double, ptr %3, align 8, !tbaa !12
  %53 = fcmp olt double %52, %51
  %54 = load double, ptr %4, align 8, !tbaa !12
  br i1 %53, label %55, label %59

55:                                               ; preds = %50
  %56 = fdiv double %52, %51
  %57 = fmul double %56, %56
  %58 = call double @llvm.fmuladd.f64(double %54, double %57, double 1.000000e+00)
  store double %58, ptr %4, align 8, !tbaa !12
  store double %51, ptr %3, align 8, !tbaa !12
  br label %62

59:                                               ; preds = %50
  %60 = fdiv double %51, %52
  %61 = call double @llvm.fmuladd.f64(double %60, double %60, double %54)
  store double %61, ptr %4, align 8, !tbaa !12
  br label %62

62:                                               ; preds = %48, %59, %55
  %indvars.iv.next = add nsw i64 %indvars.iv, %18
  %63 = icmp sgt i64 %indvars.iv.next, %19
  %64 = icmp sle i64 %indvars.iv.next, %20
  %.in = select i1 %14, i1 %63, i1 %64
  br i1 %.in, label %.lr.ph, label %.loopexit, !llvm.loop !13

.loopexit:                                        ; preds = %62, %10, %5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #5
  ret void
}

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

declare i32 @disnan_(ptr noundef) local_unnamed_addr #2

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden { double, double } @Cd(ptr noundef) local_unnamed_addr #4

; Function Attrs: mustprogress 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 = { mustprogress 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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { inlinehint 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 #5 = { 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 = !{!10, !11, i64 0}
!10 = !{!"", !11, i64 0, !11, i64 8}
!11 = !{!"double", !7, i64 0}
!12 = !{!11, !11, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


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