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

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

@.str = external hidden unnamed_addr constant [13 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [10 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @dlarrr_(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) #0 {
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i64, 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
  %17 = alloca double, align 8
  %18 = alloca double, align 8
  %19 = alloca i64, align 8
  %20 = alloca double, align 8
  %21 = alloca double, align 8
  %22 = 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
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #4
  %23 = load ptr, ptr %8, align 8, !tbaa !5
  %24 = getelementptr inbounds double, ptr %23, i32 -1
  store ptr %24, ptr %8, align 8, !tbaa !5
  %25 = load ptr, ptr %7, align 8, !tbaa !5
  %26 = getelementptr inbounds double, ptr %25, i32 -1
  store ptr %26, ptr %7, align 8, !tbaa !5
  %27 = load ptr, ptr %9, align 8, !tbaa !5
  store i64 1, ptr %27, align 8, !tbaa !9
  %28 = call double @dlamch_(ptr noundef @.str)
  store double %28, ptr %18, align 8, !tbaa !11
  %29 = call double @dlamch_(ptr noundef @.str.1)
  store double %29, ptr %13, align 8, !tbaa !11
  %30 = load double, ptr %18, align 8, !tbaa !11
  %31 = load double, ptr %13, align 8, !tbaa !11
  %32 = fdiv double %30, %31
  store double %32, ptr %20, align 8, !tbaa !11
  %33 = load double, ptr %20, align 8, !tbaa !11
  %34 = call double @sqrt(double noundef %33) #4
  store double %34, ptr %16, align 8, !tbaa !11
  store i64 1, ptr %19, align 8, !tbaa !9
  store double 0.000000e+00, ptr %17, align 8, !tbaa !11
  %35 = load ptr, ptr %7, align 8, !tbaa !5
  %36 = getelementptr inbounds double, ptr %35, i64 1
  %37 = load double, ptr %36, align 8, !tbaa !11
  %38 = fcmp oge double %37, 0.000000e+00
  br i1 %38, label %39, label %43

39:                                               ; preds = %4
  %40 = load ptr, ptr %7, align 8, !tbaa !5
  %41 = getelementptr inbounds double, ptr %40, i64 1
  %42 = load double, ptr %41, align 8, !tbaa !11
  br label %48

43:                                               ; preds = %4
  %44 = load ptr, ptr %7, align 8, !tbaa !5
  %45 = getelementptr inbounds double, ptr %44, i64 1
  %46 = load double, ptr %45, align 8, !tbaa !11
  %47 = fneg double %46
  br label %48

48:                                               ; preds = %43, %39
  %49 = phi double [ %42, %39 ], [ %47, %43 ]
  %50 = call double @sqrt(double noundef %49) #4
  store double %50, ptr %14, align 8, !tbaa !11
  %51 = load double, ptr %14, align 8, !tbaa !11
  %52 = load double, ptr %16, align 8, !tbaa !11
  %53 = fcmp olt double %51, %52
  br i1 %53, label %54, label %55

54:                                               ; preds = %48
  store i64 0, ptr %19, align 8, !tbaa !9
  br label %55

55:                                               ; preds = %54, %48
  %56 = load i64, ptr %19, align 8, !tbaa !9
  %57 = icmp ne i64 %56, 0
  br i1 %57, label %59, label %58

58:                                               ; preds = %55
  br label %124

59:                                               ; preds = %55
  %60 = load ptr, ptr %6, align 8, !tbaa !5
  %61 = load i64, ptr %60, align 8, !tbaa !9
  store i64 %61, ptr %10, align 8, !tbaa !9
  store i64 2, ptr %12, align 8, !tbaa !9
  br label %62

62:                                               ; preds = %120, %59
  %63 = load i64, ptr %12, align 8, !tbaa !9
  %64 = load i64, ptr %10, align 8, !tbaa !9
  %65 = icmp sle i64 %63, %64
  br i1 %65, label %66, label %123

66:                                               ; preds = %62
  %67 = load ptr, ptr %7, align 8, !tbaa !5
  %68 = load i64, ptr %12, align 8, !tbaa !9
  %69 = getelementptr inbounds double, ptr %67, i64 %68
  %70 = load double, ptr %69, align 8, !tbaa !11
  store double %70, ptr %11, align 8, !tbaa !11
  %71 = load double, ptr %11, align 8, !tbaa !11
  %72 = fcmp oge double %71, 0.000000e+00
  br i1 %72, label %73, label %75

73:                                               ; preds = %66
  %74 = load double, ptr %11, align 8, !tbaa !11
  br label %78

75:                                               ; preds = %66
  %76 = load double, ptr %11, align 8, !tbaa !11
  %77 = fneg double %76
  br label %78

78:                                               ; preds = %75, %73
  %79 = phi double [ %74, %73 ], [ %77, %75 ]
  %80 = call double @sqrt(double noundef %79) #4
  store double %80, ptr %15, align 8, !tbaa !11
  %81 = load double, ptr %15, align 8, !tbaa !11
  %82 = load double, ptr %16, align 8, !tbaa !11
  %83 = fcmp olt double %81, %82
  br i1 %83, label %84, label %85

84:                                               ; preds = %78
  store i64 0, ptr %19, align 8, !tbaa !9
  br label %85

85:                                               ; preds = %84, %78
  %86 = load i64, ptr %19, align 8, !tbaa !9
  %87 = icmp ne i64 %86, 0
  br i1 %87, label %89, label %88

88:                                               ; preds = %85
  br label %124

89:                                               ; preds = %85
  %90 = load ptr, ptr %8, align 8, !tbaa !5
  %91 = load i64, ptr %12, align 8, !tbaa !9
  %92 = sub nsw i64 %91, 1
  %93 = getelementptr inbounds double, ptr %90, i64 %92
  %94 = load double, ptr %93, align 8, !tbaa !11
  store double %94, ptr %11, align 8, !tbaa !11
  %95 = load double, ptr %11, align 8, !tbaa !11
  %96 = fcmp oge double %95, 0.000000e+00
  br i1 %96, label %97, label %99

97:                                               ; preds = %89
  %98 = load double, ptr %11, align 8, !tbaa !11
  br label %102

99:                                               ; preds = %89
  %100 = load double, ptr %11, align 8, !tbaa !11
  %101 = fneg double %100
  br label %102

102:                                              ; preds = %99, %97
  %103 = phi double [ %98, %97 ], [ %101, %99 ]
  %104 = load double, ptr %14, align 8, !tbaa !11
  %105 = load double, ptr %15, align 8, !tbaa !11
  %106 = fmul double %104, %105
  %107 = fdiv double %103, %106
  store double %107, ptr %21, align 8, !tbaa !11
  %108 = load double, ptr %17, align 8, !tbaa !11
  %109 = load double, ptr %21, align 8, !tbaa !11
  %110 = fadd double %108, %109
  %111 = fcmp oge double %110, 0x3FEFF7CED916872B
  br i1 %111, label %112, label %113

112:                                              ; preds = %102
  store i64 0, ptr %19, align 8, !tbaa !9
  br label %113

113:                                              ; preds = %112, %102
  %114 = load i64, ptr %19, align 8, !tbaa !9
  %115 = icmp ne i64 %114, 0
  br i1 %115, label %117, label %116

116:                                              ; preds = %113
  br label %124

117:                                              ; preds = %113
  %118 = load double, ptr %15, align 8, !tbaa !11
  store double %118, ptr %14, align 8, !tbaa !11
  %119 = load double, ptr %21, align 8, !tbaa !11
  store double %119, ptr %17, align 8, !tbaa !11
  br label %120

120:                                              ; preds = %117
  %121 = load i64, ptr %12, align 8, !tbaa !9
  %122 = add nsw i64 %121, 1
  store i64 %122, ptr %12, align 8, !tbaa !9
  br label %62, !llvm.loop !13

123:                                              ; preds = %62
  br label %124

124:                                              ; preds = %123, %116, %88, %58
  %125 = load i64, ptr %19, align 8, !tbaa !9
  %126 = icmp ne i64 %125, 0
  br i1 %126, label %127, label %129

127:                                              ; preds = %124
  %128 = load ptr, ptr %9, align 8, !tbaa !5
  store i64 0, ptr %128, align 8, !tbaa !9
  store i32 0, ptr %5, align 4
  store i32 1, ptr %22, align 4
  br label %131

129:                                              ; preds = %124
  br label %130

130:                                              ; preds = %129
  store i32 0, ptr %5, align 4
  store i32 1, ptr %22, align 4
  br label %131

131:                                              ; preds = %130, %127
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  %132 = load i32, ptr %5, align 4
  ret i32 %132
}

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

declare double @dlamch_(ptr noundef) #2

; Function Attrs: nounwind
declare double @sqrt(double noundef) #3

; 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 = { 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 #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 = !{!"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"

@.str = external hidden unnamed_addr constant [13 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [10 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @dlarrr_(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1, ptr nocapture noundef readonly %2, ptr nocapture noundef writeonly %3) local_unnamed_addr #0 {
  %5 = getelementptr inbounds i8, ptr %1, i64 -8
  store i64 1, ptr %3, align 8, !tbaa !5
  %6 = tail call double @dlamch_(ptr noundef nonnull @.str) #3
  %7 = tail call double @dlamch_(ptr noundef nonnull @.str.1) #3
  %8 = fdiv double %6, %7
  %9 = tail call double @sqrt(double noundef %8) #3
  %10 = load double, ptr %1, align 8, !tbaa !9
  %11 = fcmp ult double %10, 0.000000e+00
  %12 = fneg double %10
  %13 = select i1 %11, double %12, double %10
  %14 = tail call double @sqrt(double noundef %13) #3
  %15 = fcmp olt double %14, %9
  br i1 %15, label %.critedge, label %16

16:                                               ; preds = %4
  %17 = load i64, ptr %0, align 8, !tbaa !5
  %.not46 = icmp slt i64 %17, 2
  br i1 %.not46, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %16
  %18 = getelementptr i8, ptr %2, i64 -16
  br label %21

19:                                               ; preds = %29
  %20 = add nuw i64 %.04048, 1
  %exitcond.not = icmp eq i64 %.04048, %17
  br i1 %exitcond.not, label %._crit_edge, label %21, !llvm.loop !11

21:                                               ; preds = %.lr.ph, %19
  %.03949 = phi double [ 0.000000e+00, %.lr.ph ], [ %36, %19 ]
  %.04048 = phi i64 [ 2, %.lr.ph ], [ %20, %19 ]
  %.04147 = phi double [ %14, %.lr.ph ], [ %27, %19 ]
  %22 = getelementptr inbounds double, ptr %5, i64 %.04048
  %23 = load double, ptr %22, align 8, !tbaa !9
  %24 = fcmp oge double %23, 0.000000e+00
  %25 = fneg double %23
  %26 = select i1 %24, double %23, double %25
  %27 = tail call double @sqrt(double noundef %26) #3
  %28 = fcmp olt double %27, %9
  br i1 %28, label %.critedge, label %29

29:                                               ; preds = %21
  %30 = getelementptr double, ptr %18, i64 %.04048
  %31 = load double, ptr %30, align 8, !tbaa !9
  %32 = fcmp oge double %31, 0.000000e+00
  %33 = fneg double %31
  %34 = select i1 %32, double %31, double %33
  %35 = fmul double %.04147, %27
  %36 = fdiv double %34, %35
  %37 = fadd double %.03949, %36
  %38 = fcmp ult double %37, 0x3FEFF7CED916872B
  br i1 %38, label %19, label %.critedge

._crit_edge:                                      ; preds = %19, %16
  store i64 0, ptr %3, align 8, !tbaa !5
  br label %.critedge

.critedge:                                        ; preds = %21, %29, %4, %._crit_edge
  ret i32 0
}

declare double @dlamch_(ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @sqrt(double noundef) local_unnamed_addr #2

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 = { "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 #2 = { 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 #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 = !{!"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,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass