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

; 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.complex = type { float, float }

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

; Function Attrs: nounwind uwtable
define dso_local i32 @csrscl_(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 float, align 4
  %11 = alloca float, align 4
  %12 = alloca i64, align 8
  %13 = alloca float, align 4
  %14 = alloca float, align 4
  %15 = alloca float, align 4
  %16 = alloca float, align 4
  %17 = alloca float, align 4
  %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 4, ptr %10) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #3
  %19 = load ptr, ptr %8, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.complex, 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 %107

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

33:                                               ; preds = %105, %25
  %34 = load float, ptr %11, align 4, !tbaa !11
  %35 = load float, ptr %17, align 4, !tbaa !11
  %36 = fmul float %34, %35
  store float %36, ptr %14, align 4, !tbaa !11
  %37 = load float, ptr %13, align 4, !tbaa !11
  %38 = load float, ptr %16, align 4, !tbaa !11
  %39 = fdiv float %37, %38
  store float %39, ptr %15, align 4, !tbaa !11
  %40 = load float, ptr %14, align 4, !tbaa !11
  %41 = fcmp oge float %40, 0.000000e+00
  br i1 %41, label %42, label %44

42:                                               ; preds = %33
  %43 = load float, ptr %14, align 4, !tbaa !11
  br label %47

44:                                               ; preds = %33
  %45 = load float, ptr %14, align 4, !tbaa !11
  %46 = fneg float %45
  br label %47

47:                                               ; preds = %44, %42
  %48 = phi float [ %43, %42 ], [ %46, %44 ]
  %49 = fpext float %48 to double
  %50 = load float, ptr %13, align 4, !tbaa !11
  %51 = fcmp oge float %50, 0.000000e+00
  br i1 %51, label %52, label %54

52:                                               ; preds = %47
  %53 = load float, ptr %13, align 4, !tbaa !11
  br label %57

54:                                               ; preds = %47
  %55 = load float, ptr %13, align 4, !tbaa !11
  %56 = fneg float %55
  br label %57

57:                                               ; preds = %54, %52
  %58 = phi float [ %53, %52 ], [ %56, %54 ]
  %59 = fpext float %58 to double
  %60 = fcmp ogt double %49, %59
  br i1 %60, label %61, label %67

61:                                               ; preds = %57
  %62 = load float, ptr %13, align 4, !tbaa !11
  %63 = fcmp une float %62, 0.000000e+00
  br i1 %63, label %64, label %67

64:                                               ; preds = %61
  %65 = load float, ptr %17, align 4, !tbaa !11
  store float %65, ptr %10, align 4, !tbaa !11
  store i64 0, ptr %12, align 8, !tbaa !9
  %66 = load float, ptr %14, align 4, !tbaa !11
  store float %66, ptr %11, align 4, !tbaa !11
  br label %97

67:                                               ; preds = %61, %57
  %68 = load float, ptr %15, align 4, !tbaa !11
  %69 = fcmp oge float %68, 0.000000e+00
  br i1 %69, label %70, label %72

70:                                               ; preds = %67
  %71 = load float, ptr %15, align 4, !tbaa !11
  br label %75

72:                                               ; preds = %67
  %73 = load float, ptr %15, align 4, !tbaa !11
  %74 = fneg float %73
  br label %75

75:                                               ; preds = %72, %70
  %76 = phi float [ %71, %70 ], [ %74, %72 ]
  %77 = fpext float %76 to double
  %78 = load float, ptr %11, align 4, !tbaa !11
  %79 = fcmp oge float %78, 0.000000e+00
  br i1 %79, label %80, label %82

80:                                               ; preds = %75
  %81 = load float, ptr %11, align 4, !tbaa !11
  br label %85

82:                                               ; preds = %75
  %83 = load float, ptr %11, align 4, !tbaa !11
  %84 = fneg float %83
  br label %85

85:                                               ; preds = %82, %80
  %86 = phi float [ %81, %80 ], [ %84, %82 ]
  %87 = fpext float %86 to double
  %88 = fcmp ogt double %77, %87
  br i1 %88, label %89, label %92

89:                                               ; preds = %85
  %90 = load float, ptr %16, align 4, !tbaa !11
  store float %90, ptr %10, align 4, !tbaa !11
  store i64 0, ptr %12, align 8, !tbaa !9
  %91 = load float, ptr %15, align 4, !tbaa !11
  store float %91, ptr %13, align 4, !tbaa !11
  br label %96

92:                                               ; preds = %85
  %93 = load float, ptr %13, align 4, !tbaa !11
  %94 = load float, ptr %11, align 4, !tbaa !11
  %95 = fdiv float %93, %94
  store float %95, ptr %10, align 4, !tbaa !11
  store i64 1, ptr %12, align 8, !tbaa !9
  br label %96

96:                                               ; preds = %92, %89
  br label %97

97:                                               ; preds = %96, %64
  %98 = load ptr, ptr %6, align 8, !tbaa !5
  %99 = load ptr, ptr %8, align 8, !tbaa !5
  %100 = getelementptr inbounds %struct.complex, ptr %99, i64 1
  %101 = load ptr, ptr %9, align 8, !tbaa !5
  %102 = call i32 @f2c_csscal(ptr noundef %98, ptr noundef %10, ptr noundef %100, ptr noundef %101)
  %103 = load i64, ptr %12, align 8, !tbaa !9
  %104 = icmp ne i64 %103, 0
  br i1 %104, label %106, label %105

105:                                              ; preds = %97
  br label %33

106:                                              ; preds = %97
  store i32 0, ptr %5, align 4
  store i32 1, ptr %18, align 4
  br label %107

107:                                              ; preds = %106, %24
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  %108 = load i32, ptr %5, align 4
  ret i32 %108
}

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

declare double @slamch_(ptr noundef) #2

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

declare i32 @f2c_csscal(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 = !{!"float", !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 @csrscl_(ptr noundef %0, ptr nocapture noundef readonly %1, ptr noundef %2, ptr noundef %3) local_unnamed_addr #0 {
  %5 = alloca float, align 4
  %6 = alloca float, align 4
  %7 = alloca float, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %7) #3
  %8 = load i64, ptr %0, align 8, !tbaa !5
  %9 = icmp slt i64 %8, 1
  br i1 %9, label %43, label %10

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

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

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

.thread:                                          ; preds = %28
  %39 = fdiv float %.027, %.029
  store float %39, ptr %5, align 4, !tbaa !9
  %40 = call i32 @f2c_csscal(ptr noundef nonnull %0, ptr noundef nonnull %5, ptr noundef %2, ptr noundef %3) #3
  br label %43

41:                                               ; preds = %28, %16
  %storemerge = phi float [ %17, %16 ], [ %29, %28 ]
  %.130 = phi float [ %18, %16 ], [ %.029, %28 ]
  %.1 = phi float [ %.027, %16 ], [ %30, %28 ]
  store float %storemerge, ptr %5, align 4, !tbaa !9
  %42 = call i32 @f2c_csscal(ptr noundef nonnull %0, ptr noundef nonnull %5, ptr noundef %2, ptr noundef %3) #3
  br label %16

43:                                               ; preds = %.thread, %4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #3
  call void @llvm.lifetime.end.p0(i64 4, 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 @slamch_(ptr noundef) local_unnamed_addr #2

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

declare i32 @f2c_csscal(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 = !{!"float", !7, i64 0}


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