; LLVM IR from niuyishuai/PDCABB :: LAPACK_BLAS/BLAS/SRC (dznrm2)

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

22:                                               ; preds = %3
  %23 = load ptr, ptr %6, align 8, !tbaa !5
  %24 = load i64, ptr %23, align 8, !tbaa !9
  %25 = icmp slt i64 %24, 1
  br i1 %25, label %26, label %27

26:                                               ; preds = %22, %3
  store double 0.000000e+00, ptr %15, align 8, !tbaa !11
  br label %151

27:                                               ; preds = %22
  store double 0.000000e+00, ptr %16, align 8, !tbaa !11
  store double 1.000000e+00, ptr %13, align 8, !tbaa !11
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = load i64, ptr %28, align 8, !tbaa !9
  %30 = sub nsw i64 %29, 1
  %31 = load ptr, ptr %6, align 8, !tbaa !5
  %32 = load i64, ptr %31, align 8, !tbaa !9
  %33 = mul nsw i64 %30, %32
  %34 = add nsw i64 %33, 1
  store i64 %34, ptr %7, align 8, !tbaa !9
  %35 = load ptr, ptr %6, align 8, !tbaa !5
  %36 = load i64, ptr %35, align 8, !tbaa !9
  store i64 %36, ptr %8, align 8, !tbaa !9
  store i64 1, ptr %12, align 8, !tbaa !9
  br label %37

37:                                               ; preds = %142, %27
  %38 = load i64, ptr %8, align 8, !tbaa !9
  %39 = icmp slt i64 %38, 0
  br i1 %39, label %40, label %45

40:                                               ; preds = %37
  %41 = load i64, ptr %12, align 8, !tbaa !9
  %42 = load i64, ptr %7, align 8, !tbaa !9
  %43 = icmp sge i64 %41, %42
  %44 = zext i1 %43 to i32
  br label %50

45:                                               ; preds = %37
  %46 = load i64, ptr %12, align 8, !tbaa !9
  %47 = load i64, ptr %7, align 8, !tbaa !9
  %48 = icmp sle i64 %46, %47
  %49 = zext i1 %48 to i32
  br label %50

50:                                               ; preds = %45, %40
  %51 = phi i32 [ %44, %40 ], [ %49, %45 ]
  %52 = icmp ne i32 %51, 0
  br i1 %52, label %53, label %146

53:                                               ; preds = %50
  %54 = load i64, ptr %12, align 8, !tbaa !9
  store i64 %54, ptr %9, align 8, !tbaa !9
  %55 = load ptr, ptr %5, align 8, !tbaa !5
  %56 = load i64, ptr %9, align 8, !tbaa !9
  %57 = getelementptr inbounds %struct.doublecomplex, ptr %55, i64 %56
  %58 = getelementptr inbounds %struct.doublecomplex, ptr %57, i32 0, i32 0
  %59 = load double, ptr %58, align 8, !tbaa !13
  %60 = fcmp une double %59, 0.000000e+00
  br i1 %60, label %61, label %99

61:                                               ; preds = %53
  %62 = load i64, ptr %12, align 8, !tbaa !9
  store i64 %62, ptr %9, align 8, !tbaa !9
  %63 = load ptr, ptr %5, align 8, !tbaa !5
  %64 = load i64, ptr %9, align 8, !tbaa !9
  %65 = getelementptr inbounds %struct.doublecomplex, ptr %63, i64 %64
  %66 = getelementptr inbounds %struct.doublecomplex, ptr %65, i32 0, i32 0
  %67 = load double, ptr %66, align 8, !tbaa !13
  store double %67, ptr %11, align 8, !tbaa !11
  %68 = load double, ptr %11, align 8, !tbaa !11
  %69 = fcmp oge double %68, 0.000000e+00
  br i1 %69, label %70, label %72

70:                                               ; preds = %61
  %71 = load double, ptr %11, align 8, !tbaa !11
  br label %75

72:                                               ; preds = %61
  %73 = load double, ptr %11, align 8, !tbaa !11
  %74 = fneg double %73
  br label %75

75:                                               ; preds = %72, %70
  %76 = phi double [ %71, %70 ], [ %74, %72 ]
  store double %76, ptr %14, align 8, !tbaa !11
  %77 = load double, ptr %16, align 8, !tbaa !11
  %78 = load double, ptr %14, align 8, !tbaa !11
  %79 = fcmp olt double %77, %78
  br i1 %79, label %80, label %90

80:                                               ; preds = %75
  %81 = load double, ptr %16, align 8, !tbaa !11
  %82 = load double, ptr %14, align 8, !tbaa !11
  %83 = fdiv double %81, %82
  store double %83, ptr %11, align 8, !tbaa !11
  %84 = load double, ptr %13, align 8, !tbaa !11
  %85 = load double, ptr %11, align 8, !tbaa !11
  %86 = load double, ptr %11, align 8, !tbaa !11
  %87 = fmul double %85, %86
  %88 = call double @llvm.fmuladd.f64(double %84, double %87, double 1.000000e+00)
  store double %88, ptr %13, align 8, !tbaa !11
  %89 = load double, ptr %14, align 8, !tbaa !11
  store double %89, ptr %16, align 8, !tbaa !11
  br label %98

90:                                               ; preds = %75
  %91 = load double, ptr %14, align 8, !tbaa !11
  %92 = load double, ptr %16, align 8, !tbaa !11
  %93 = fdiv double %91, %92
  store double %93, ptr %11, align 8, !tbaa !11
  %94 = load double, ptr %11, align 8, !tbaa !11
  %95 = load double, ptr %11, align 8, !tbaa !11
  %96 = load double, ptr %13, align 8, !tbaa !11
  %97 = call double @llvm.fmuladd.f64(double %94, double %95, double %96)
  store double %97, ptr %13, align 8, !tbaa !11
  br label %98

98:                                               ; preds = %90, %80
  br label %99

99:                                               ; preds = %98, %53
  %100 = load ptr, ptr %5, align 8, !tbaa !5
  %101 = load i64, ptr %12, align 8, !tbaa !9
  %102 = getelementptr inbounds %struct.doublecomplex, ptr %100, i64 %101
  %103 = call double @d_imag(ptr noundef %102)
  %104 = fcmp une double %103, 0.000000e+00
  br i1 %104, label %105, label %141

105:                                              ; preds = %99
  %106 = load ptr, ptr %5, align 8, !tbaa !5
  %107 = load i64, ptr %12, align 8, !tbaa !9
  %108 = getelementptr inbounds %struct.doublecomplex, ptr %106, i64 %107
  %109 = call double @d_imag(ptr noundef %108)
  store double %109, ptr %11, align 8, !tbaa !11
  %110 = load double, ptr %11, align 8, !tbaa !11
  %111 = fcmp oge double %110, 0.000000e+00
  br i1 %111, label %112, label %114

112:                                              ; preds = %105
  %113 = load double, ptr %11, align 8, !tbaa !11
  br label %117

114:                                              ; preds = %105
  %115 = load double, ptr %11, align 8, !tbaa !11
  %116 = fneg double %115
  br label %117

117:                                              ; preds = %114, %112
  %118 = phi double [ %113, %112 ], [ %116, %114 ]
  store double %118, ptr %14, align 8, !tbaa !11
  %119 = load double, ptr %16, align 8, !tbaa !11
  %120 = load double, ptr %14, align 8, !tbaa !11
  %121 = fcmp olt double %119, %120
  br i1 %121, label %122, label %132

122:                                              ; preds = %117
  %123 = load double, ptr %16, align 8, !tbaa !11
  %124 = load double, ptr %14, align 8, !tbaa !11
  %125 = fdiv double %123, %124
  store double %125, ptr %11, align 8, !tbaa !11
  %126 = load double, ptr %13, align 8, !tbaa !11
  %127 = load double, ptr %11, align 8, !tbaa !11
  %128 = load double, ptr %11, align 8, !tbaa !11
  %129 = fmul double %127, %128
  %130 = call double @llvm.fmuladd.f64(double %126, double %129, double 1.000000e+00)
  store double %130, ptr %13, align 8, !tbaa !11
  %131 = load double, ptr %14, align 8, !tbaa !11
  store double %131, ptr %16, align 8, !tbaa !11
  br label %140

132:                                              ; preds = %117
  %133 = load double, ptr %14, align 8, !tbaa !11
  %134 = load double, ptr %16, align 8, !tbaa !11
  %135 = fdiv double %133, %134
  store double %135, ptr %11, align 8, !tbaa !11
  %136 = load double, ptr %11, align 8, !tbaa !11
  %137 = load double, ptr %11, align 8, !tbaa !11
  %138 = load double, ptr %13, align 8, !tbaa !11
  %139 = call double @llvm.fmuladd.f64(double %136, double %137, double %138)
  store double %139, ptr %13, align 8, !tbaa !11
  br label %140

140:                                              ; preds = %132, %122
  br label %141

141:                                              ; preds = %140, %99
  br label %142

142:                                              ; preds = %141
  %143 = load i64, ptr %8, align 8, !tbaa !9
  %144 = load i64, ptr %12, align 8, !tbaa !9
  %145 = add nsw i64 %144, %143
  store i64 %145, ptr %12, align 8, !tbaa !9
  br label %37, !llvm.loop !15

146:                                              ; preds = %50
  %147 = load double, ptr %16, align 8, !tbaa !11
  %148 = load double, ptr %13, align 8, !tbaa !11
  %149 = call double @sqrt(double noundef %148) #5
  %150 = fmul double %147, %149
  store double %150, ptr %15, align 8, !tbaa !11
  br label %151

151:                                              ; preds = %146, %26
  %152 = load double, ptr %15, align 8, !tbaa !11
  store double %152, ptr %10, align 8, !tbaa !11
  %153 = load double, ptr %10, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, 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 8, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  ret double %153
}

; 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

declare double @d_imag(ptr noundef) #3

; Function Attrs: nounwind
declare double @sqrt(double 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { "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 #4 = { nounwind "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 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = !{!14, !12, i64 0}
!14 = !{!"", !12, i64 0, !12, i64 8}
!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 double @f2c_dznrm2(ptr nocapture noundef readonly %0, ptr noundef %1, ptr nocapture noundef readonly %2) local_unnamed_addr #0 {
  %4 = getelementptr inbounds i8, ptr %1, i64 -16
  %5 = load i64, ptr %0, align 8, !tbaa !5
  %6 = icmp slt i64 %5, 1
  br i1 %6, label %48, label %7

7:                                                ; preds = %3
  %8 = load i64, ptr %2, align 8, !tbaa !5
  %9 = icmp slt i64 %8, 1
  br i1 %9, label %48, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %7
  %10 = add nsw i64 %5, -1
  %11 = mul nsw i64 %8, %10
  %12 = add nuw nsw i64 %11, 1
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %44
  %.073 = phi double [ %.2, %44 ], [ 0.000000e+00, %.lr.ph.preheader ]
  %.05972 = phi double [ %.261, %44 ], [ 1.000000e+00, %.lr.ph.preheader ]
  %.06271 = phi i64 [ %45, %44 ], [ 1, %.lr.ph.preheader ]
  %13 = getelementptr inbounds %struct.doublecomplex, ptr %4, i64 %.06271
  %14 = load double, ptr %13, align 8, !tbaa !9
  %15 = fcmp une double %14, 0.000000e+00
  br i1 %15, label %16, label %28

16:                                               ; preds = %.lr.ph
  %17 = fcmp oge double %14, 0.000000e+00
  %18 = fneg double %14
  %19 = select i1 %17, double %14, double %18
  %20 = fcmp olt double %.073, %19
  br i1 %20, label %21, label %25

21:                                               ; preds = %16
  %22 = fdiv double %.073, %19
  %23 = fmul double %22, %22
  %24 = tail call double @llvm.fmuladd.f64(double %.05972, double %23, double 1.000000e+00)
  br label %28

25:                                               ; preds = %16
  %26 = fdiv double %19, %.073
  %27 = tail call double @llvm.fmuladd.f64(double %26, double %26, double %.05972)
  br label %28

28:                                               ; preds = %21, %25, %.lr.ph
  %.160 = phi double [ %24, %21 ], [ %27, %25 ], [ %.05972, %.lr.ph ]
  %.1 = phi double [ %19, %21 ], [ %.073, %25 ], [ %.073, %.lr.ph ]
  %29 = tail call double @d_imag(ptr noundef nonnull %13) #4
  %30 = fcmp une double %29, 0.000000e+00
  br i1 %30, label %31, label %44

31:                                               ; preds = %28
  %32 = tail call double @d_imag(ptr noundef nonnull %13) #4
  %33 = fcmp oge double %32, 0.000000e+00
  %34 = fneg double %32
  %35 = select i1 %33, double %32, double %34
  %36 = fcmp olt double %.1, %35
  br i1 %36, label %37, label %41

37:                                               ; preds = %31
  %38 = fdiv double %.1, %35
  %39 = fmul double %38, %38
  %40 = tail call double @llvm.fmuladd.f64(double %.160, double %39, double 1.000000e+00)
  br label %44

41:                                               ; preds = %31
  %42 = fdiv double %35, %.1
  %43 = tail call double @llvm.fmuladd.f64(double %42, double %42, double %.160)
  br label %44

44:                                               ; preds = %28, %41, %37
  %.261 = phi double [ %40, %37 ], [ %43, %41 ], [ %.160, %28 ]
  %.2 = phi double [ %35, %37 ], [ %.1, %41 ], [ %.1, %28 ]
  %45 = add nuw nsw i64 %.06271, %8
  %.not = icmp sgt i64 %45, %12
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !12

._crit_edge:                                      ; preds = %44
  %46 = tail call double @sqrt(double noundef %.261) #4
  %47 = fmul double %.2, %46
  br label %48

48:                                               ; preds = %3, %7, %._crit_edge
  %.058 = phi double [ %47, %._crit_edge ], [ 0.000000e+00, %7 ], [ 0.000000e+00, %3 ]
  ret double %.058
}

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

declare double @d_imag(ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @sqrt(double noundef) local_unnamed_addr #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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 nofree nounwind willreturn memory(write) "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 #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 = !{!"long", !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 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}


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