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

; 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 [2 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @drscl_(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 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
  %17 = alloca double, align 8
  %18 = 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) #3
  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
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #3
  %19 = load ptr, ptr %8, align 8, !tbaa !5
  %20 = getelementptr inbounds double, ptr %19, i32 -1
  store ptr %20, ptr %8, align 8, !tbaa !5
  %21 = load ptr, ptr %6, align 8, !tbaa !5
  %22 = load i64, ptr %21, align 8, !tbaa !9
  %23 = icmp sle i64 %22, 0
  br i1 %23, label %24, label %25

24:                                               ; preds = %4
  store i32 0, ptr %5, align 4
  store i32 1, ptr %18, align 4
  br label %102

25:                                               ; preds = %4
  %26 = call double @dlamch_(ptr noundef @.str)
  store double %26, ptr %17, align 8, !tbaa !11
  %27 = load double, ptr %17, align 8, !tbaa !11
  %28 = fdiv double 1.000000e+00, %27
  store double %28, ptr %16, align 8, !tbaa !11
  %29 = call i32 @dlabad_(ptr noundef %17, ptr noundef %16)
  %30 = load ptr, ptr %7, align 8, !tbaa !5
  %31 = load double, ptr %30, align 8, !tbaa !11
  store double %31, ptr %11, align 8, !tbaa !11
  store double 1.000000e+00, ptr %13, align 8, !tbaa !11
  br label %32

32:                                               ; preds = %100, %25
  %33 = load double, ptr %11, align 8, !tbaa !11
  %34 = load double, ptr %17, align 8, !tbaa !11
  %35 = fmul double %33, %34
  store double %35, ptr %14, align 8, !tbaa !11
  %36 = load double, ptr %13, align 8, !tbaa !11
  %37 = load double, ptr %16, align 8, !tbaa !11
  %38 = fdiv double %36, %37
  store double %38, ptr %15, align 8, !tbaa !11
  %39 = load double, ptr %14, align 8, !tbaa !11
  %40 = fcmp oge double %39, 0.000000e+00
  br i1 %40, label %41, label %43

41:                                               ; preds = %32
  %42 = load double, ptr %14, align 8, !tbaa !11
  br label %46

43:                                               ; preds = %32
  %44 = load double, ptr %14, align 8, !tbaa !11
  %45 = fneg double %44
  br label %46

46:                                               ; preds = %43, %41
  %47 = phi double [ %42, %41 ], [ %45, %43 ]
  %48 = load double, ptr %13, align 8, !tbaa !11
  %49 = fcmp oge double %48, 0.000000e+00
  br i1 %49, label %50, label %52

50:                                               ; preds = %46
  %51 = load double, ptr %13, align 8, !tbaa !11
  br label %55

52:                                               ; preds = %46
  %53 = load double, ptr %13, align 8, !tbaa !11
  %54 = fneg double %53
  br label %55

55:                                               ; preds = %52, %50
  %56 = phi double [ %51, %50 ], [ %54, %52 ]
  %57 = fcmp ogt double %47, %56
  br i1 %57, label %58, label %64

58:                                               ; preds = %55
  %59 = load double, ptr %13, align 8, !tbaa !11
  %60 = fcmp une double %59, 0.000000e+00
  br i1 %60, label %61, label %64

61:                                               ; preds = %58
  %62 = load double, ptr %17, align 8, !tbaa !11
  store double %62, ptr %10, align 8, !tbaa !11
  store i64 0, ptr %12, align 8, !tbaa !9
  %63 = load double, ptr %14, align 8, !tbaa !11
  store double %63, ptr %11, align 8, !tbaa !11
  br label %92

64:                                               ; preds = %58, %55
  %65 = load double, ptr %15, align 8, !tbaa !11
  %66 = fcmp oge double %65, 0.000000e+00
  br i1 %66, label %67, label %69

67:                                               ; preds = %64
  %68 = load double, ptr %15, align 8, !tbaa !11
  br label %72

69:                                               ; preds = %64
  %70 = load double, ptr %15, align 8, !tbaa !11
  %71 = fneg double %70
  br label %72

72:                                               ; preds = %69, %67
  %73 = phi double [ %68, %67 ], [ %71, %69 ]
  %74 = load double, ptr %11, align 8, !tbaa !11
  %75 = fcmp oge double %74, 0.000000e+00
  br i1 %75, label %76, label %78

76:                                               ; preds = %72
  %77 = load double, ptr %11, align 8, !tbaa !11
  br label %81

78:                                               ; preds = %72
  %79 = load double, ptr %11, align 8, !tbaa !11
  %80 = fneg double %79
  br label %81

81:                                               ; preds = %78, %76
  %82 = phi double [ %77, %76 ], [ %80, %78 ]
  %83 = fcmp ogt double %73, %82
  br i1 %83, label %84, label %87

84:                                               ; preds = %81
  %85 = load double, ptr %16, align 8, !tbaa !11
  store double %85, ptr %10, align 8, !tbaa !11
  store i64 0, ptr %12, align 8, !tbaa !9
  %86 = load double, ptr %15, align 8, !tbaa !11
  store double %86, ptr %13, align 8, !tbaa !11
  br label %91

87:                                               ; preds = %81
  %88 = load double, ptr %13, align 8, !tbaa !11
  %89 = load double, ptr %11, align 8, !tbaa !11
  %90 = fdiv double %88, %89
  store double %90, ptr %10, align 8, !tbaa !11
  store i64 1, ptr %12, align 8, !tbaa !9
  br label %91

91:                                               ; preds = %87, %84
  br label %92

92:                                               ; preds = %91, %61
  %93 = load ptr, ptr %6, align 8, !tbaa !5
  %94 = load ptr, ptr %8, align 8, !tbaa !5
  %95 = getelementptr inbounds double, ptr %94, i64 1
  %96 = load ptr, ptr %9, align 8, !tbaa !5
  %97 = call i32 @f2c_dscal(ptr noundef %93, ptr noundef %10, ptr noundef %95, ptr noundef %96)
  %98 = load i64, ptr %12, align 8, !tbaa !9
  %99 = icmp ne i64 %98, 0
  br i1 %99, label %101, label %100

100:                                              ; preds = %92
  br label %32

101:                                              ; preds = %92
  store i32 0, ptr %5, align 4
  store i32 1, ptr %18, align 4
  br label %102

102:                                              ; preds = %101, %24
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #3
  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
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  %103 = load i32, ptr %5, align 4
  ret i32 %103
}

; 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

declare i32 @dlabad_(ptr noundef, ptr noundef) #2

declare i32 @f2c_dscal(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #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 = { "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 = !{!"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}


; 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 [2 x i8], align 1

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

10:                                               ; preds = %4
  %11 = tail call double @dlamch_(ptr noundef nonnull @.str) #3
  store double %11, ptr %7, align 8, !tbaa !9
  %12 = fdiv double 1.000000e+00, %11
  store double %12, ptr %6, align 8, !tbaa !9
  %13 = call i32 @dlabad_(ptr noundef nonnull %7, ptr noundef nonnull %6) #3
  %14 = load double, ptr %1, align 8, !tbaa !9
  br label %15

15:                                               ; preds = %40, %10
  %.029 = phi double [ %14, %10 ], [ %.130, %40 ]
  %.027 = phi double [ 1.000000e+00, %10 ], [ %.1, %40 ]
  %16 = load double, ptr %7, align 8, !tbaa !9
  %17 = fmul double %.029, %16
  %18 = insertelement <2 x double> poison, double %17, i64 0
  %19 = insertelement <2 x double> %18, double %.027, i64 1
  %20 = fcmp oge <2 x double> %19, zeroinitializer
  %21 = fneg <2 x double> %19
  %22 = select <2 x i1> %20, <2 x double> %19, <2 x double> %21
  %23 = extractelement <2 x double> %22, i64 0
  %24 = extractelement <2 x double> %22, i64 1
  %25 = fcmp ogt double %23, %24
  %26 = fcmp une double %.027, 0.000000e+00
  %or.cond = and i1 %26, %25
  br i1 %or.cond, label %40, label %27

27:                                               ; preds = %15
  %28 = load double, ptr %6, align 8, !tbaa !9
  %29 = fdiv double %.027, %28
  %30 = insertelement <2 x double> poison, double %29, i64 0
  %31 = insertelement <2 x double> %30, double %.029, i64 1
  %32 = fcmp oge <2 x double> %31, zeroinitializer
  %33 = fneg <2 x double> %31
  %34 = select <2 x i1> %32, <2 x double> %31, <2 x double> %33
  %35 = extractelement <2 x double> %34, i64 0
  %36 = extractelement <2 x double> %34, i64 1
  %37 = fcmp ogt double %35, %36
  br i1 %37, label %40, label %.thread

.thread:                                          ; preds = %27
  %38 = fdiv double %.027, %.029
  store double %38, ptr %5, align 8, !tbaa !9
  %39 = call i32 @f2c_dscal(ptr noundef nonnull %0, ptr noundef nonnull %5, ptr noundef %2, ptr noundef %3) #3
  br label %42

40:                                               ; preds = %27, %15
  %storemerge = phi double [ %16, %15 ], [ %28, %27 ]
  %.130 = phi double [ %17, %15 ], [ %.029, %27 ]
  %.1 = phi double [ %.027, %15 ], [ %29, %27 ]
  store double %storemerge, ptr %5, align 8, !tbaa !9
  %41 = call i32 @f2c_dscal(ptr noundef nonnull %0, ptr noundef nonnull %5, ptr noundef %2, ptr noundef %3) #3
  br label %15

42:                                               ; preds = %.thread, %4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #3
  ret i32 0
}

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

declare double @dlamch_(ptr noundef) local_unnamed_addr #2

declare i32 @dlabad_(ptr noundef, ptr noundef) local_unnamed_addr #2

declare i32 @f2c_dscal(ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

; 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 = { 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}


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